Create object tag in javascript

W

whitelined

Hi,

I'm trying to create an 'object' element. I'm using the following code
as a test:

window.onload = function()
{
var obj = document.createElement('object');
obj.type = 'text/html';

obj.data = 'test.html';
document.getElementById('content').appendChild(obj);
}

It works fine is Firefox, but not in IE. In IE, the DOM explorer shows
the 'object' has been created, and attached to the content div, but
nothing is displayed. Does anyone know why?

Thanks for any help

Regards

Aaron
 
T

Thomas 'PointedEars' Lahn

whitelined said:
whitelined said:
It works fine is Firefox, but not in IE. In IE, the DOM explorer shows
the 'object' has been created, and attached to the content div, but
nothing is displayed. Does anyone know why?
IE's <object> support is very basic and doesn't support loading HTML.

http://www.howtocreate.co.uk/wrongWithIE/?chapter=Object+Tags

The situation may have improved on IE 7. I haven't tested it.
[...]

Thanks for the quick reply. Looks like I'm going to have to make a
class that'll produce an object for FF and other supporting browsers,
and iframe for IE. I did test my code in IE7, and it didn't like it.

There are no classes in your targeted environments, and there is no good
reason not to use an `iframe' element everywhere. Besides, you would have a
hard time telling user agents apart:

http://pointedears.de/scripts/test/whatami


Please trim your quotes:

http://www.jibbering.com/faq/faq_notes/clj_posts.html#ps1Post


PointedEars
 
W

whitelined

Thomas said:
There are no classes in your targeted environments, and there is no good
reason not to use an `iframe' element everywhere. Besides, you would have a
hard time telling user agents apart:

I'm being anal and trying to stick to the xhtml strict standard, so no
iframes. I've created a class, it works in opera, FF, IE, safari, so I'm
happy.
 
T

Thomas 'PointedEars' Lahn

whitelined said:
I'm being anal and trying to stick to the xhtml strict standard, so no
iframes. I've created a class, it works in opera, FF, IE, safari, so I'm
happy.

Ignorance is bliss until it kicks you in the back.


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,161
Latest member
GertrudeMa
Top