Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using jQuery to change all instances of <object> to <iframe> for IE support

I am wondering if it is possible to use jQuery to switch out all <object> tags on a site for <iframe> tags when loading on IE 8 and below. In essence, this would allow the page to be XHTML 1.1 valid and not have to be double-coded all the time, eliminating the need to spend so much time focusing on non-standard browsers.

The data= attribute would need to be changed to src=, I'd like to insert frameborder="0", and all of the style values for the <object> tag would also need to be set for the <iframe> tag.

My goal here is not to create a debate on <iframe>s vs <object>s, I just think that this would be a huge tmie saver, and encourage proper, strict xhtml coding practices.

Thanks for any input!

like image 990
geckomist Avatar asked Nov 06 '22 13:11

geckomist


1 Answers

For a basic rundown on how to change an element's type see jQuery convert DOM element to different type (no idea whether it'll work properly in XHTML, but it well might), but I don't think this is a good idea at all. I can see it cause delays on older machines (on which IE6 runs), and obviously, it won't work when JavaScript is disabled. All that to achieve valid code? Not a good idea IMO.

Before doing that, if the code has to be valid under any circumstances, I'd consider serving different code to IE6 on server side.

like image 51
Pekka Avatar answered Nov 12 '22 18:11

Pekka