Click to See Complete Forum and Search --> : Cross Browser Iframe Referencing


demonseed101
02-25-2003, 10:48 AM
I'm making a site which has an iframe and a number of links, which when pressed change the source of the Iframe.

I was using this code:

function setframe(cnt)
{
if (cnt==1){document.getElementById("frame").src='page1.html';}

if (cnt==2){document.getElementById("frame").src='page2.html';}

if (cnt==3){document.getElementById("frame").src='page3.html';}
}


activated by a link such as <a href="#" onclick="javascript:setframe(1);">Page 1</a>

the iframe has the id of frame.

However, I've noticed that it works fine in IE 5+, Mozilla and Netscape 6+, however, it doesn't work in Opera 6+.

And as I'm a huge fan of this browser I'd like for it to work.

Can some one tell me how to reference the iframe for it to work in more browsers?

Many thanks

demonseed101

khalidali63
02-25-2003, 12:45 PM
It should not work in NS/Mozilla as well ( I know it doesn't work for .*_*).
iframe is an HTML tag which does not have an id attribute.
And if it works for IE,then ..well what can I say.

Conclusion use the name attribute for iframes instead of id.

cheers

Khalid