View Full Version : How to access hyperlinks automatically??

06-16-2003, 01:31 PM
Hi, does any1 out there know how write a Javascript that access a hyperlink, then access another hyperlink in the same website?

06-16-2003, 02:49 PM
with the click() function:


06-16-2003, 03:22 PM
Hi brothercake, thanks a lot!
But i've a problem here.. Besides "document.getElementById();", is there any other methods?? Bcos i'm currently writing a program which access a website and i'm not sure how to get the ElementById()...

Btw, if a page, EG: www.testing.com/test.jsp?openview contains javascript:makechart().
How can i access the above mentioned Javascript from a local page??

06-16-2003, 04:54 PM
Well you have to assign the link an ID attribute, for example:

<a href="something.html" id="mylink">

then it would be


BTW - you shouldn't use the javascript: pseudo protocol in links; because it leaves nothing for non-JS browsers; it's better to go

<a href="somepage.html" onclick="return myFunction()">

then in myFunction you return false, to prevent the link being followed:

function myFunction()

// do whatever

return false;


06-16-2003, 05:02 PM
Oic.. but if the <A HREF> doesn't contain ID, that means i can't get that method rite?? Coz i'm accessing someone else's page, and it has many hyperlinks, but it simply uses <A HREF="page1.jsp">...
Ok, the scenario is i'm writing a JSP which will auto 'click' on the hyperlinks in the person's website. Coz each hyperlink contains some data file. The trouble is the person uses a Javascript function to open a new window for loading out a data file. And i'm suppose to call that javascript in that webpage, from my JSP... Do u think it's possible for me to do so???

06-16-2003, 11:22 PM
You can't access someone else's page, programmatically, if it's hosted at another domain.