Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Netscape/Javascript/document.write/style problem

Status
Not open for further replies.

glancep

Programmer
Aug 3, 2001
6
US
Alright... this is a weird one, and it's driving me crazy... so any help is appreciated!

Let me start by saying, this relates to Netscape 4.7... I don't know about other versions.

Here's the deal: I want to have a button that will change the location when clicked (via location.href=''). However, I also want this to be accessible to non-javascript users... so, I am putting a <NOSCRIPT> tag that has a link to the same place. That way, if they don't have javascript, it'll show the link.

Anyways, the problem is, I have to use document.write to display the button on the page (so that it won't show up for non-js browsers). Netscape really doesn't seem to like my document.write line. Here's the code:

<SCRIPT LANGUAGE=&quot;Javascript&quot; TYPE=&quot;text/javascript&quot;>
<!-- hide script to old browsers
document.write('<INPUT TYPE=&quot;Button&quot; VALUE=&quot; >> &quot; ONCLICK=&quot;location.href='js-link.html'&quot; STYLE=&quot;Cursor: Hand;&quot;>');
document.write('label that goes right of button');
// -->
</SCRIPT>
<NOSCRIPT>
<A HREF=&quot;non-js-link.html&quot;>Non JS Link</A>
</NOSCRIPT>

The problem is, when I open it in Netscape, the button is on the RIGHT of the text, when quite obviously it should be on the left. If you look at the source in Netscape it will actually show that it wrote TWO buttons, one on the left and one on the right.... for some reason only the right one shows up. I might also mention that if you look at the source closely in Netscape, you'll notice that the second button's STYLE attribute has been misspelled to &quot;TTYLE&quot;??

So...
...why is Netscape outputing the button twice (and the text only once, for that matter)?
...why is only the right button showing up? (btw: if you maximize/restore the window, I've had Netscape to show both buttons... weird!)
...why does Netscape hate me so much?

I should also mention that if you remove the STYLE attribute from the document.write line, it behaves nicely. Why?? I mean, I understand that Netscape doesn't support the Cursor style, but it should just ignore it. If I copy the same exact button code and put it on the page directly (not via javascript) Netscape renders it just fine.

Anybody help?!?

Thanks a lot....
Gideon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top