Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Mar 2008
    Posts
    61
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Weird DOM issue in IE

    So I have the following code in javascript that creates an iframe:
    Code:
    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"

    Code:
    <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.
    Last edited by WebmasterLULZ; 09-30-2010 at 07:24 AM.

  • #2
    Regular Coder
    Join Date
    Aug 2010
    Posts
    967
    Thanks
    19
    Thanked 211 Times in 209 Posts
    It's a well known bug
    try it like this....

    Code:
    <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>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •