Forum Moderators: open

Message Too Old, No Replies

Document.location does not work IN Netscape

Document.location doesnt work if placed inside a form tag in Netscape

         

megh

6:35 am on Apr 26, 2004 (gmt 0)

10+ Year Member



Why doesnt document.location not work if placed within a form tag. I am using Netscape 7.1 . If i bring it outside the form tag, It works fine on IE and NS. But if I put it inside the form tag, It uses the form tag's action attribute or if the action attribute is not set for the form, as expected it refreshes the same page.
Here are the two codes that work and the other does not.
-----Works Fine----
<button onClick="document.location='abc.asp'">Click here</button>
<form name="frm1" method="post" action="home.asp">
</form>
-------------------
-----This piece of code does not---------
<form name="frm1" method="post" action="home.asp">
<button onClick="document.location='abc.asp?CatalogID=100098'">Click here</button>
</form>
-------------------

Looks like that Form tag is the only problem.

MD

dcrombie

11:09 am on Apr 26, 2004 (gmt 0)



You could try:

<button onClick="self.location.href='abc.asp';">

or:

<button onClick="self.location.href='abc.asp'; return false;">

will1480

2:01 pm on Apr 26, 2004 (gmt 0)

10+ Year Member



yeah, if that doesnt work, then you can create a seperate function to be called or you can create an image and use an <a> tag. Also, try document.location.href="url" or use a seperate function:

<form action=""><button onClick="javascript:go_here('url')">
</form>

<script type="javascript">
function go_here(x){document.location.href=x;}
</script>

megh

2:38 am on Apr 27, 2004 (gmt 0)

10+ Year Member



Hi Guys,
Thanks for the reply. return false; does work. I think i get the reason behind it too. Anyhoo appreciate your help.

MD