...

View Full Version : Weird DOM issue in IE



WebmasterLULZ
09-30-2010, 08:16 AM
So I have the following code in javascript that creates an iframe:


var iframe = document.createElement("iframe");
iframe.id = 'offerframe';
iframe.name = 'offerframe';
iframe.width = '975';
iframe.height = '650';
iframe.align = 'center';
iframe.src = 'http://example.com';
document.getElementById("offer-frame-div").appendChild(iframe);


It works fine in Firefox and Safari but in IE8 it generates the iframe name attribute to "submitName"



<iframe width="975" height="650" align="center" id="offerframe" submitName="offerframe" src="http://example.com">


Notice how it sets all the other attributes fine, however the name attribute is now called "submitName". This issue only happens in IE. This there any alternatives to setting my iframe name dynamically with javascript.

DaveyErwin
09-30-2010, 12:57 PM
It's a well known bug
try it like this....


<div id="offer">xxxxxx</div>


<script>
iframe = null;
try{
iframe = document.createElement('<IFRAME name="offerframe">');}
catch(e){
iframe = document.createElement('IFRAME');
iframe.name = 'offerframe';}
iframe.id = 'offerframe';
iframe.width = '975';
iframe.height = '650';
iframe.align = 'center';
iframe.src = 'http://example.com';

document.getElementById("offer").appendChild(iframe);

alert(document.getElementById("offer").innerHTML)

</script>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum