/    Sign up×
Community /Pin to ProfileBookmark

Auto click link

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.

to post a comment
JavaScript

9 Comments(s)

Copy linkTweet thisAlerts:
@AdamGundryJul 18.2003 — I believe you can get the link value of the first link using [b]document.links[0].href[/b], and changing the number for different links.

Adam
Copy linkTweet thisAlerts:
@aseeker84authorJul 18.2003 — 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?
Copy linkTweet thisAlerts:
@AdamGundryJul 18.2003 — 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.
Copy linkTweet thisAlerts:
@aseeker84authorJul 18.2003 — 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.
Copy linkTweet thisAlerts:
@AdamGundryJul 19.2003 — Correct - browser security restrictions prevent you from accessing other domains. You will need server-side code to be able to extract the link.

Adam
Copy linkTweet thisAlerts:
@aseeker84authorJul 21.2003 — 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?
Copy linkTweet thisAlerts:
@AdamGundryJul 21.2003 — 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
Copy linkTweet thisAlerts:
@aseeker84authorJul 22.2003 — 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?
Copy linkTweet thisAlerts:
@AdamGundryJul 22.2003 — I expect PHP could do it (perhaps using regular expressions) - I suggest you post a question in the PHP forum.

Adam
×

Success!

Help @aseeker84 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...