Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting document links

Status
Not open for further replies.

AaronBeau

MIS
Jan 29, 2008
89
US
I have a page that I want to open 5 different pages one at a time, after it opens the page I want it to pop up an alert displaying the the second link from the links[] array from that page.

Here is the code:
Code:
<script type="text/javascript">
function openSites() {

var openOneAtATime=new Array()
openOneAtATime[0]="[URL unfurl="true"]http://www.ebay.com"[/URL]
openOneAtATime[1]="[URL unfurl="true"]http://www.google.com"[/URL]
openOneAtATime[2]="[URL unfurl="true"]http://www.cnn.com"[/URL]
openOneAtATime[3]="[URL unfurl="true"]http://www.yahoo.com"[/URL]
openOneAtATime[4]="[URL unfurl="true"]http://www.amazon.com"[/URL]

var i=0;
for (i=0;i<openOneAtATime.length;i++) {
    setTimeout("WindowObjectReference = window.open(openOneAtATime[i],"window1")",5000);

    setTimeout("alert(window1.links[1])",5000*(i+.8));

    setTimeout("WindowObjectReference.close()",5000*(i+1.2))
    }
}
</script>

I tried:
setTimeout("alert(window1.links[1])",5000*(i+.8));
and
setTimeout("alert(WindowObjectReference.links[1])",5000*(i+.8));

but neither worked.

----------------------------
Beau71 - MCSA
----------------------------
 
But you're making the same mistakes...
Read that carefully again,... every apostrophe, quotes, where the declaration of variable be placed,... are important - no exaggeration. You've to understand why the revisions were made and what are the difference.
 
sorry, i just copied and pasted from the other post....i made all those changes and that worked.

But i want to add new functionality, which i cannot get to work.

the new piece of code is:
setTimeout("alert(window1.links[1])",5000*(i+.8));

if it is just
setTimeout("alert(links[1])",5000*(i+.8));

it works but displays the link from the original page not the newly opened page.

----------------------------
Beau71 - MCSA
----------------------------
 
I have made some progress....
it seems that if i do
Code:
setTimeout("alert(ecKillWindow.document.links[1])",5000*(i+0.3));

it will give me the results of the second link on the page ONLY IF the page is located on the same domain; however, if I try to get the links from a page that isn't part of the same domain I am getting an error:

Error: Permission denied to get property Window.document
Source File: Line: 328

----------------------------
Beau71 - MCSA
----------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top