...

View Full Version : Changing source of an iframe.



Lee Brenner
07-15-2002, 05:03 PM
This works in IE:

document.myIFrame.location.replace("somePage.html");

But not in Netscape or Mozilla. Can someone suggest the best cross-platform way to change the src of an I-Frame?

Also, a div I am using as a button has a css attribute set:

cursor: pointer;

This works correctly in Netscape/ Mozilla...a hand-cursor appears over my div. But in IE the default cursors show up (pointer and text-bar). However, if I use:

cursor: hand;

then exactly the opposite happens. Any advice?

Thanks in advance!

joh6nn
07-15-2002, 06:28 PM
the best way to get the iframe to work, cross browser, is this:

window.frames['myIFrame'].location = 'somePage.htm';

IE has a proprietary setting called 'hand', which means, if it's real important to you, you'll need to set up a small piece of JavaScript to see if the current browser is IE, and change the appropriate style.

<script>
if ( document.all ) {
document.all['objectname'].style.cursor = 'hand';
}
</script>

x_goose_x
07-15-2002, 06:38 PM
Check this out:

http://webdesign.about.com/library/weekly/aa081501a.htm

That's just how they work.

Try this:

<p onmouseover="if (navigator.appName=='Microsoft Internet Explorer'&&parseInt(navigator.appVersion)>=4) { this.style.cursor='hand' }else{ this.style.cursor='pointer' }">hello</p>

Lee Brenner
07-15-2002, 06:44 PM
Thanks for the tips...here's how I ended up dealing with the problems:



//works in all browsers I'm targeting
frames['myIFrame'].location.href = "somePage.html";

//works in all browsers I'm targeting
{
cursor: pointer;
cursor: hand;
}

jkd
07-15-2002, 07:19 PM
I just set its src property:

refToIframe.src = 'newpage.html';

Works everywhere.

Lee Brenner
07-15-2002, 08:25 PM
Sorry, but I can't get it to work by just setting the src property. I mean, I can when I first place the tag. But I can't programatically change it that way.

jkd
07-15-2002, 10:05 PM
refToIFRAME.setAttribute('src', 'newpage.html');

also works.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum