#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Location
    sydney
    Posts
    2
    Rep Power
    0

    Question javascript in netscape


    hi,
    im in the testing stages of a site im making called "communism loves you!" and i was wondering if anyone could look at the java on my page...it seems to work fine in ie but netscape cannot do the random image script and the gofade script...

    the adress is http://mida.idx.com.au/commie/

    if anyone can send me a revised verion of the scripts or something that would be great...

    thanks

    qwertyisg d
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Sep 2000
    Posts
    763
    Rep Power
    0
    Your Javascript is not working because Mozilla/NS does not use the document.all object.

    You should take a look at this article on Devshed about the Mozilla DOM, which NS uses.

    ROUGH GUIDE TO THE DOM

    Eclipce
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Location
    sydney
    Posts
    2
    Rep Power
    0
    so how would i change it...
    don't worry about the go fade script but the random image i defietly need...
    can someone tell me how i would change it so it works in both ns and ie?
    note i didn't write the script...
    a freind did and he doesn't know how to change it either....

    thanks
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Sep 2000
    Posts
    763
    Rep Power
    0
    Try this.

    Code:
    function GetRandomPic() {
    
    var imgObj = document.getElementByID("WOW");
    
    imgObj.src = "http:path/to/server"+rand(15)+".jpg";
    
    }
    Eclipce

    Edit: Stupid smillies
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    44
    Rep Power
    12

    form.value


    hello i was just playin around a bit with javascript and i was wondering y this code does not work on ns/mozilla browser

    Code:
    <script LANGUAGE="JavaScript">
    <!--
    function addtext(blah) {
    tutform.msg.value = (tutform.msg.value + blah);
    tutform.msg.focus();
    }
    
    //-->
    </SCRIPT>
    then in that form i call:
    Code:
    <TEXTAREA rows="25" cols="80" name="msg" TABINDEX="1"></TEXTAREA>
    <INPUT TYPE="button" VALUE="Note Open" name="sup" onClick=javascript:addtext("[note]");>
    if anyone could tell me how to properly make this code work for most browsers that would be great.

    and also i was wondering if theres any way i can make it so that it inserts the text wher the cursor currently is.

    thanks
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Sep 2000
    Posts
    763
    Rep Power
    0
    Like I said in my post above, read the article on the DOM here at devshed. It explains how to manipulate elements in Mozilla/NS.

    As for your code, I would do this.
    Code:
    <script LANGUAGE="JavaScript">
    <!--
    function addtext(blah) {
    var msgObj = document.getElementById("msg");
    var prevText  = msgObj.value;
    
    msgObj.value = prevText + blah;
    
    msgObj.focus();
    }
    
    //-->
    </SCRIPT>
    <!-- You must have an id attibute in this for it to work -->
    <TEXTAREA rows="15" cols="40" id="msg" name="msg" TABINDEX="1"></TEXTAREA>
    <!-- Notice the single quotes -->
    <INPUT TYPE="button" VALUE="Note Open" name="sup" onClick="javascript:addtext('[note]');">
    This works. The javascript in the input tag should be one word, but I guess vB is messing it up.

    Eclipce
    Last edited by Eclipce; February 26th, 2003 at 09:27 AM.

IMN logo majestic logo threadwatch logo seochat tools logo