Wilfredo
03-02-2006, 09:19 AM
'ello there
I have scoured the internet to find a solution to my problem but can't find anything remotely close, so I hoped someone here might be able to help...
I have a page with two frames. A main frame, and a smaller navigation frame. I am trying to code a button in Javascript on the navigation frame that brings up a new window displaying a list of all the links it found on the main frame.
The button uses the following Javascript...
function listLinks(doc){
var newWin = window.open();
for(var i = 0; i < doc.links.length; i++){
newWin.document.write("<A HREF = \"");
newWin.document.write(doc.links[i].href);
newWin.document.write("\">");
newWin.document.write(doc.links[i].innerText);
newWin.document.write("</A><BR>");
}
}
This works perfect if I pass down "document" to the function, so that it simply displays the list of links on the navigation frame, but I want it to display the links of the main frame instead, so I tried passing "top.content_pane" down to the funcion. Like so...
<button name="getlinks" onclick="listLinks(top.content_pane)";>
But I get the error message telling me "links" is null or undefined. I think it is having problems getting the array of links out of the main frame? Does anyone know a way around this at all?
Much much appreciated...
Will
I have scoured the internet to find a solution to my problem but can't find anything remotely close, so I hoped someone here might be able to help...
I have a page with two frames. A main frame, and a smaller navigation frame. I am trying to code a button in Javascript on the navigation frame that brings up a new window displaying a list of all the links it found on the main frame.
The button uses the following Javascript...
function listLinks(doc){
var newWin = window.open();
for(var i = 0; i < doc.links.length; i++){
newWin.document.write("<A HREF = \"");
newWin.document.write(doc.links[i].href);
newWin.document.write("\">");
newWin.document.write(doc.links[i].innerText);
newWin.document.write("</A><BR>");
}
}
This works perfect if I pass down "document" to the function, so that it simply displays the list of links on the navigation frame, but I want it to display the links of the main frame instead, so I tried passing "top.content_pane" down to the funcion. Like so...
<button name="getlinks" onclick="listLinks(top.content_pane)";>
But I get the error message telling me "links" is null or undefined. I think it is having problems getting the array of links out of the main frame? Does anyone know a way around this at all?
Much much appreciated...
Will