NS does not accept linkname.click

N

nntp

<a id="hiddenLink1" name="hiddenLink1" href="page1.htm"
target="someTarget1" >1 </a>
<a id="hiddenLink2" name="hiddenLink2" href="page2.htm"
target="someTarget1" >2 </a>


<A href="javascript:donothing();"
onClick="hiddenLink1.click();setTimeout('hiddenLink2.click()',2000);">open
two</A>

works in Opera and IE, but not in NS. In NS, it has no action at all.

I tried document.links['hiddenLink1'].click(); IE gave me error, object
document.link.hiddenLink1 can not be empty.
 
R

Randy Webb

nntp said:
<a id="hiddenLink1" name="hiddenLink1" href="page1.htm"
target="someTarget1" >1 </a>
<a id="hiddenLink2" name="hiddenLink2" href="page2.htm"
target="someTarget1" >2 </a>


<A href="javascript:donothing();"
onClick="hiddenLink1.click();setTimeout('hiddenLink2.click()',2000);">open
two</A>
http://jibbering.com/faq/#FAQ4_24


works in Opera and IE, but not in NS. In NS, it has no action at all.

Did you check the Javascript Console? Tools>Web Development>Javascript
Console.

Error: hiddenLink1 is not defined.
 
L

Lee

nntp said:
<a id="hiddenLink1" name="hiddenLink1" href="page1.htm"
target="someTarget1" >1 </a>
<a id="hiddenLink2" name="hiddenLink2" href="page2.htm"
target="someTarget1" >2 </a>


<A href="javascript:donothing();"
onClick="hiddenLink1.click();setTimeout('hiddenLink2.click()',2000);">open
two</A>

works in Opera and IE, but not in NS. In NS, it has no action at all.

It has an action, but you need to open the Javascript console to see it.
It should display an error because there is no global variable named
"hiddenLink1". IE, and apparently Opera, allows you to get away with
that, but it's poor practice. To get a reference to an element with a
given id, use getElementById(), as in:

document.getElementById('hiddenLink1').click();

However, I don't think links have a "click()" method in Netscape.

You also shouldn't use the javascript: pseudo-protocol like that.
It may cause errors if Javascript is disabled.

<html>
<head>
<script type="text/javascript">
function openTwoWindows(url1,url2){
window.open(url1);
setTimeout("window.open('"+url2+"')",2000);
}
</script>
</head>
<body>
<a href="errorPage.html"
onclick="openTwoWindows('page1.htm','page2.htm');return false"
open two</a>
</body>
</html>
 
N

nntp

Do you know how I can do click in NS?

Here is the one with getelementbyid

<a id="hiddenLink1" name="hiddenLink1" href="http://www.google.com"
target="someTarget1" >1 </a>
<a id="hiddenLink2" name="hiddenLink2" href="http://www.yahoo.com"
target="someTarget1" >2 </a>
<SCRIPT language="JavaScript">
function donothing() {return ;}
</SCRIPT>

<A href="#" onClick="document.getElementById('hiddenLink1').click();
setTimeout('document.getElementById(\'hiddenLink2\').click()',2000);">open
2</A>

Works in IE and Opera. STILL not working in NS. I guess it is the click()
not working in NS;

I need to pass the REFERRER into it, so I really need click(). Frames are
not an option.
 
R

RobG

nntp said:
<a id="hiddenLink1" name="hiddenLink1" href="page1.htm"
target="someTarget1" >1 </a>
<a id="hiddenLink2" name="hiddenLink2" href="page2.htm"
target="someTarget1" >2 </a>


<A href="javascript:donothing();"
onClick="hiddenLink1.click();setTimeout('hiddenLink2.click()',2000);">open
two</A>

works in Opera and IE, but not in NS. In NS, it has no action at all.

I tried document.links['hiddenLink1'].click(); IE gave me error, object
document.link.hiddenLink1 can not be empty.

You don't need it to click the link. Try:

<A href="#"
onclick="
location = document.getElementById('hiddenLink1');

setTimeout('location=document.getElementById(\'hiddenLink2\')',2000)
;">open 1</A>

Incidentally, the setTimeout will not work (I think)
because you navigate to the first link, so the page is
unloaded. You can't execute a script from a page that is
no longer in the browser (gee, wouldn't that really screw
with users's minds!! Isn't the unload function nasty
enough?)

Cheers, Rob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top