...

View Full Version : redirecting all hyperlinks?



shraga18
04-24-2008, 06:34 PM
Hi everyone.

1. I have a page which consists of two iframes. The first one displays an external site, and I'm looking for a way that any link clicked on that iframe will open in the second iframe. Is there any script which can be included in the iframe which will make all links open in iframe 2? Failing that, can anyone think of a way to do this?

2. Is there any script which allows one to DRAG a link between iframes?

TIA!

mjlorbet
04-24-2008, 09:19 PM
1) you can use script on your links like


<a href="#" onclick='window.parent.document.getElementById("yourOtherIframe").document.location = "mypage6.html";'>Visit mypage 6</a>

note: iframes are wierd and there is a special syntax to targetting them for script functions, please use the forum search and locate those many other topics on the same question.
1b) retargeting all the links on a particular page


function retarget(){
var anchors = document.getElementsByTagName("a");
for(var a = 0; a < anchors.length; a++){
anchors[a].onclick=function(){window.parent.document.getElementById("otherframe").document.location = anchors[a].href;};
anchors[a].href = "#";
}
}


2) no.

shraga18
04-24-2008, 11:16 PM
1) you can use script on your links like


<a href="#" onclick='window.parent.document.getElementById("yourOtherIframe").document.location = "mypage6.html";'>Visit mypage 6</a>


Mjlorbeet, thanks for the help. The problem, unfortunately, is that the site in my first iframe is an external one, I therefor can't append code to it's links, which is the big obstacle here.

Any further help greatly appreciated!

mjlorbet
04-25-2008, 12:30 AM
yep, the cross-domain stuff will getcha



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum