PDA

View Full Version : Is it possible to modify iframe to detect url?



darkus
10-29-2008, 10:55 PM
1) Script Title: Iframe SSI script II

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/iframessi2.htm

3) Describe problem:

I am planning on using this script on my page and wanted to know if this is possible:

If the iframe is navigated to a certain url by the user clicking on the link (in this example google.com) then the script would detect that the iframe is now on google.com and would simply do a redirect of the entire page to google.com (or whatever url i decide on) so that the entire page now would display google.com instead of it being inside the iframe only.

Thanks!!!!!!!!!!!!!!!!!!!!!!!!!!

rangana
10-30-2008, 02:20 AM
Add highlighted:


function resizeCaller() {
var dyniframe=new Array()
for (i=0; i<iframeids.length; i++){
if(document.getElementById(iframeids[i]).src.indexOf('google.com')>1)
location.href='http://www.google.com';
if (document.getElementById)
resizeIframe(iframeids[i])
//reveal iframe for lower end browsers? (see var above):
if ((document.all || document.getElementById) && iframehide=="no"){
var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i])
tempobj.style.display="block"
}
}
}


If the iframe's URL contains "google.com", it will redirect the page to google.com

Hope that helps.

darkus
10-30-2008, 12:04 PM
Add highlighted:


function resizeCaller() {
var dyniframe=new Array()
for (i=0; i<iframeids.length; i++){
if(document.getElementById(iframeids[i]).src.indexOf('google.com')>1)
location.href='http://www.google.com';
if (document.getElementById)
resizeIframe(iframeids[i])
//reveal iframe for lower end browsers? (see var above):
if ((document.all || document.getElementById) && iframehide=="no"){
var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i])
tempobj.style.display="block"
}
}
}


If the iframe's URL contains "google.com", it will redirect the page to google.com

Hope that helps.

Thanks so much for the help!!

But for some reason this isn't working.. it worked if I had the original ifram call ask for google.com, but if it starts on another page and a user clicks a link to google it doesnt work for some reason. ?