Click to See Complete Forum and Search --> : Auto click link
aseeker84
07-18-2003, 10:23 AM
Looking for a way to execute a link displayed on a page I opened as a popup. The popup page was opened from a link I know, but I then need to create another popup for the link found on the first popup. I need a auto link process (like I clicked on it) or a way to examine the source for the first popup to extract the link value.
AdamGundry
07-18-2003, 10:55 AM
I believe you can get the link value of the first link using document.links[0].href, and changing the number for different links.
Adam
aseeker84
07-18-2003, 11:54 AM
That looks like it might work. How do I specify in the parent page which document link I want in the popup page? I assume I would use the reference to the popup page, but I can't seem to find an example of the syntax to use. Plus, do I need a delay to wait for the popup to load?
AdamGundry
07-18-2003, 01:27 PM
You should be able to use something like this (untested - you might need a setTimeout delay for the second line, I'm not sure):
var w = window.open("page.html");
w.location = w.document.links[0].href;
Adam
P.S. Remember both pages must be in the same domain for this to work. You can change which link to load by changing the number in square brackets.
P.P.S. Of course, according to the W3C you should not be using popups.
aseeker84
07-18-2003, 01:57 PM
By same domain, do you mean I can't be on my site, launch a popup (I know...bad) for say www.msn.com and expect to be able to get the value of their first link on the www.msn.com home page? This IS what I am looking for. Not www.msn.com specifically, but you get the idea.
AdamGundry
07-19-2003, 11:38 AM
Correct - browser security restrictions prevent you from accessing other domains. You will need server-side code to be able to extract the link.
Adam
aseeker84
07-21-2003, 09:08 AM
Thanks for the info. Do you know anyway to force a click on the link once the page is open? How about actually reading the source somehow?
AdamGundry
07-21-2003, 12:04 PM
Unfortunately, you have virtually no access to pages from other domains, so you cannot read the source. You will have to use server-side code.
As far as I'm aware, direct mouse control is not possible in Javascript.
Adam
aseeker84
07-22-2003, 10:16 AM
Do you know what kind of server side code would be required? I develop in PHP. Should I look there for ways to do this?
AdamGundry
07-22-2003, 11:29 AM
I expect PHP could do it (perhaps using regular expressions) - I suggest you post a question in the PHP forum.
Adam