Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Nov 2002
    Posts
    672
    Thanks
    1
    Thanked 1 Time in 1 Post

    Problems with netscapes lack of javascript support

    I have a script I'm using on my board. It uses document.getElementById (something that is documented to work in Netscape 7). Yet I've showed the page to Netscape users and they don't see it. netscape doesn't seem to tell you if it encounters any script problems (probably because if it did, it would have an error for every standard-valid script that they refuse to add support for) so I have no idea if document.getElementById is the problem or not. But I told the person testing the page for me to enter this in his address bar

    javascript:alert(document.getElementById())

    When I do that (IE) I get null. When he does it, he gets nothing. He's on Netscape 7.1 The script uses the following:

    if conditions (if, else)

    document.getElementsByTagName()
    document.getElementById()
    string.substring()
    string.indexOf()
    string.lastIndexOf()
    string.split()
    object.innerHTML
    variables
    arrays
    functions
    for loops (for, break)
    + (concentration)
    = (value assignment)
    +=
    variables
    == (for if conditions)

    I really have my doubts. Is there anything in that list above that Netscape actually has support for? Because scripts either work or they don't, it's hard to know why when it doesn't tell you what the problem is. The url to the pages with this script in action are any threads on http://xfox.proboards21.com/index.cgi?board=test. Worst case scenario is I tell the script not to execute for netscape users, unless it's not going past the document.getElementById() in the if. (search for /* on the page)

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I don't really know where to start with this question - you've voiced so many untested assumptions, and they're all so wrong, it's hard to dignify it with a rational response.

    Sorry .. nothing personal man ... but don't assume that something is broken just because you don't understand how it works.

    --------------------------------

    Firstly - mozilla has a Javascript debugger - it's in "tools > web development > javascript console". I don't know if the Netscape branded distributions include that, but moz is more useful for development anyway - it has (or had?) a DOM inspector, which makes DOM scripting a great deal easier to debug.

    Secondly - mozilla supports more standard methods and properties than any other browser, by a long, long way. Everything you've listed there works just fine, if implemented correctly.

    Thirdly - you can't alert() a collection like that - that's why IE returns null. But moz sees it for what it is - an alert() with no arguments, and so it throws an exception. Try something like this:
    Code:
    javascript:alert(typeof document.getElementById);void(null);
    And it will alert "function"

    --------------------------------

    Right, now that your preconceptions are out of the way What's the actual problem? I didn't notice any obvious scripts on that page - where is the script, and what is it supposed to do?
    Last edited by brothercake; 12-20-2003 at 06:52 AM.
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

  • #3
    Regular Coder
    Join Date
    Nov 2002
    Posts
    672
    Thanks
    1
    Thanked 1 Time in 1 Post
    /* Copyright XFox Prower. You may not use this script. */
    //headers

    url="http://www.techsonic.net/xfox/board/layout/"
    for(i=0;i<17;i++)
    {
    window['c'+i]=new Image();
    window['c'+i].src=url+'c'+i+'.gif';
    }

    layout=Array(7)
    layout[0]='<table cellspacing="0" cellpadding="0"><tr><td><img src="'+c0.src+'" /></td><td background="'+c1.src+'" width="198" colspan="5"></td><td><img src="'+c2.src+'" /></td></tr><tr><td background="'+c3.src+'" width="9" rowspan="5"></td><td><img src="'+c4.src+'" /></td><td background="'+c5.src+'" width="117" valign="middle">';
    layout[1]='</td><td><img src="'+c6.src+'" /></td><td bgcolor="#f06020" width="63">'
    layout[2]='</td><td><img src="'+c7.src+'" /></td><td background="'+c8.src+'" width="9" rowspan="5" /></td></tr><tr><td bgcolor="#f8f8f8" width="198" height="3" colspan="5"></td></tr><tr><td width="198" height="27" bgcolor="#000000" colspan="5">';
    layout[3]='</td></tr><tr><td bgcolor="#f8f8f8" width="198" height="3" colspan="5"></td></tr><tr><td bgcolor="#000000" width="198" height="3" colspan="5"></td></tr></table><table cellspacing="0" cellpadding="0"><tr><td background="'+c3.src+'" width="9" rowspan="3"></td><td><img src="'+c9.src+'" /></td><td background="'+c10.src+'" width="180" align="center" valign="middle">';
    layout[4]='</td><td><img src="'+c11.src+'" /></td><td background="'+c8.src+'" width="9" rowspan="3"></td></tr><tr><td bgcolor="#f8b800" height="3" width="198" colspan="3"></td></tr></table><table cellspacing="0" cellpadding="0"><tr><td background="'+c3.src+'" width="9" rowspan="3"></td><td bgcolor="#000000" width="120" height="21"><font color="white">&nbsp;&nbsp;&nbsp;Posts: ';
    layout[5]='</font></td><td><img src="'+c12.src+'" /></td></tr><tr><td colspan="3"><img src="'+c13.src+'" /></td></tr></table><table cellspacing="0" cellpadding="0"><tr><td background="'+c3.src+'" width="9"></td><td><img src="'+c14.src+'" /></td><td bgcolor="#b86000" width="156" height="69" valign="top">';
    layout[6]='</td><td><img src="'+c15.src+'" /></td></tr><tr><td colspan="4"><img src="'+c16.src+'" /></td></tr></table>';

    function star()
    {
    p='<img src="http://4d5.net/boardimages/star.gif" />';
    posts=eval(posts);
    rank='<font style="font-size:6px">&nbsp;</font>';
    if(posts>49){rank+=p}
    if(posts>99){rank+=p}
    if(posts>249){rank+=p}
    if(posts>499){rank+=p}
    if(posts>999){rank+=p}
    if(posts>1999){rank+=p}
    if(posts>3499){rank+=p}
    if(posts>5999){rank+=p}
    if(posts>9999){rank+=p}
    return rank;
    }

    function main()
    {
    for(i=0;i<document.getElementsByTagName('td').length;i++)
    {
    if(document.getElementsByTagName('td').item(i).className=="windowbg"||document.getElementsByTagName( 'td').item(i).className=="windowbg2")
    {
    x=document.getElementsByTagName('td').item(i).innerHTML;
    if(x.indexOf('<FONT size=1><FONT size=-1>')==0&&x.indexOf('<BR>Guest<BR>')==-1)
    {
    y=x.indexOf('</A>');
    if(x.indexOf('member is <B>online</B>')>0){memstat="<center><b>Online</b></center>"}else{memstat="<center>Offline</center>"}
    username='&nbsp;&nbsp;'+x.substring(27,y+4);
    posts=x.substring(x.indexOf('Posts:')+6,x.lastIndexOf('<BR>'));
    sep=x.split('<BR><BR>');
    for(j=0;j<sep.length;j++)
    {
    if(sep[j].indexOf('<CENTER>')!=-1)
    {
    avator=sep[j].substring(sep[j].indexOf('<CENTER>'),sep[j].length)+'</center>';
    avtext='<font style="font-size:12px">&nbsp;'+sep[j+1]+'</font><br />';
    break;
    }
    }
    if(x.indexOf('female.gif')>0){gender='<img src="http://4d5.net/boardimages/female.gif" />'}
    else
    {
    if(x.indexOf('male.gif')>0){gender='<img src="http://4d5.net/boardimages/male.gif" />'}
    else{gender=''}
    }
    contact=sep[sep.length-2]
    conind=contact.indexOf('<BR>')
    con1=contact.substring(0,conind)
    con2=contact.substring(conind+4,contact.length)
    contact='<br />'+con1+con2+'&nbsp;&nbsp;'+gender;
    output=layout[0]+star()+layout[1]+memstat+layout[2]+username+layout[3]+avator+layout[4]+posts+layout[5]+avtext+contact+layout[6];
    ind=i;
    document.getElementsByTagName('td').item(ind).innerHTML=output;
    }
    }
    }
    }

    //end header, start footer
    main();


    </script>

    To see the source of the page it's designed to do the searching with indexOf(), it's the threads in the above forum link (previous post). In IE, you'll see that the avator areas (image, posts, contact info) are moved around and an image layout is there. It doesn't show up in netscape. I was a bit ticked about it (I guess that showed sorry heh). However, as far as I know, the page didn't crash and complain of a javascript error. I'm concerned that if the script made the page unstable since Netscape couldn't handle it, or if it found something it didn't support and backed down to avoid trouble, or if it stopped reading all scripts on the page due to this one. It's probably document.getElementsByTagName or split() that it doesn't work with. I don't know of a place documenting what Netscape supports, what Netscape's version of that command is, and what version implements them. I thought an if command would be imple enough to test which commands work and which don't. I don't know what that void thing was, could you explain?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •