473,396 Members | 2,037 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

changing the data attribute of <object>

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?

any help appreciated, micha
Jul 23 '05 #1
1 9074


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/
Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

23
by: Andrew Thompson | last post by:
This is intended to fix a long standing (cough)Java(cough) problem with which I'm sure some of you will be familiar. Sun recommends using the <OBJECT>/<EMBED> elements to cater for Java...
4
by: KC | last post by:
Could some one explain to me the casting rules for sending generic lists, ex. List<Person>, to a function that accepts List<object>? I cannot get the following easy-cheesy app to work. I get the...
2
by: ACaunter | last post by:
Hi all, I have the following code in the html part of my asp.net page to display an activeX control object which is like a picture viewer: ---------------------------- Response.Write("<object...
4
by: colson | last post by:
Hi, If I have a class A, and a List<List<object>> containing instances of A. How do I explicitly cast List<List<object>> as List<List<A>>?
4
by: msnews.microsoft.com | last post by:
hello every one i am using media player in internet explorer but i cannot access it directly in code behind, so do you know a way to access it? <object id="video123"...
3
by: mark4asp | last post by:
According to this <http://css-discuss.incutio.com/?page=BoxModelHack> IE6 will display differently to the W3C standard. Only IE6/strict and I suppose IE 7 display correctly. IE 6 transitional and...
0
by: diver | last post by:
I was using an <iframe> to load a website within my .aspx page. When the user "logged out", I called a javascript break out function to breakout of the frame and load the appropriate page when...
9
by: Stephan Steiner | last post by:
Hi I seem to have a bit of trouble understanding one bit of how generics work: In C#, every class automatically derives from object, and inherits a bunch of properties (i.e. ToString()). Thus,...
4
by: Alan Silver | last post by:
Hello, I have an <objecttag that is used to display a Flash file. I would like the whole Flash file to be a link. The obvious thought would be to do this... <a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.