Click to See Complete Forum and Search --> : what page is open?


leprkn
06-27-2003, 02:35 PM
i need a script that checks a particular frame to see what page is loaded and then load an image based on that open page. here's an example:

if frame.right == "home.html" then
img src=home_img.gif
else
img src=nothome_img.gif
endif

any suggestions?

Jona
06-27-2003, 02:44 PM
You might want a setTimeout() to run the function every certain amount of seconds, or use a function to attach the onClick() method to run the function... Either will work. Anyways, you'll want something like this:


if(parent.frames["rightFrameName"].location.href=="http://yoursite.com/home.html" || parent.frames["rightFrameName"].location.href=="http://www.yoursite.com/home.html"){
document.images["theNameoftheImage"].src="theImage.gif";
} else {
document.images["theNameoftheImage"].src="theOtherImage.gif";
}


[Jona]

SlankenOgen
06-27-2003, 02:46 PM
function findUrl()
{
var x = -1;

var Url = parent.frames[1].location.href;

x = Url.search(/home.html/);

alert(x+":"+Url);

if(x > -1)
{
document.myImg.src = "home_img.gif";
return;
}else{
document.myImg.src = "nothome_img.gif";
}

}

The frames index can be a name or integer.