View Full Version : Changing source of an iframe.

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


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!

07-15-2002, 07: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.

if ( document.all ) {
document.all['objectname'].style.cursor = 'hand';

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


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, 07: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;

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

refToIframe.src = 'newpage.html';

Works everywhere.

Lee Brenner
07-15-2002, 09: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.

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

also works.