chotiwallah wrote:
this is the html:
<a href="javascript:change();">change</a>
<object data="a.htm" type="text/html" width="200" height="200"
id="obj"></object>
and this the javascript:
function change()
{
document.getElementById('obj').setAttribute('data' ,'b.htm');
alert(document.getElementById('obj').data);
}
this little script shall change the data of the <object> from 'a.htm'
to 'b.htm' - which it actually does. the alert() shows 'b.htm' as
data.
but: 'b.htm' is not displayed, the content of object doesn't change -
same in firefox, ns, ie.
what am i missing?
That works only in Opera I think, in general it is easier to use an iframe
<iframe name="iframeName" src="a.htm"></iframe>
and then a link
<a href="b.htm" target="iframeName">change</a>
as iframes work much better in current browsers than objects and as that
way you do not need any script to load the new page, a normal link works.
I know that the <iframe> element is not in HTML 4.01 strict but the
<object> implementation in browsers is bad and inconsistent enough to
use <iframe> with the transitional HTML 4.01 DTD. Even if you insist on
using script to load the new page you will find that
window.frames.iframeName.location.href = 'b.html';
works consistently in browsers from Opera 6, Netscape 6, IE 4 on while
you have found that scripting object is a pain.
--
Martin Honnen
http://JavaScript.FAQTs.com/