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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Apr 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    get element issue with IE

    Hi,

    I have this code on a page to call a file and it is not working in IE, it seems to work in all other browsers. How can I get this working in IE? Please help.

    Code:
    <script>
    <!--
       function getSaleInfo() {
         document.getElementById('st_code').innerHTML='<iframe src="http://domain.com/affiliate/salejs.php?amount=15&transaction=B" alt="" width=400 height=400>';
     }
     window.onload = getSaleInfo;
     // -->
     </script>
     <div id="st_code" style="visibility:hidden"></div>
    Thanks.

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,865
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    Try
    Code:
    document.getElementById('st_code').innerHTML='<iframe src="http://domain.com/affiliate/salejs.php?amount=15&transaction=B" alt="" width="400" height="400"></iframe>';
    btw, you won't see anything unless you remove visibility:hidden
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    Senior Coder Arbitrator's Avatar
    Join Date
    Mar 2006
    Location
    Splendora, Texas, United States of America
    Posts
    3,387
    Thanks
    32
    Thanked 288 Times in 282 Posts
    Quote Originally Posted by markc View Post
    Code:
    <script>
    <!--
       function getSaleInfo() {
         document.getElementById('st_code').innerHTML='<iframe src="http://domain.com/affiliate/salejs.php?amount=15&transaction=B" alt="" width=400 height=400>';
     }
     window.onload = getSaleInfo;
     // -->
     </script>
     <div id="st_code" style="visibility:hidden"></div>
    Better form would be: (A) omitting the SGML comment markers (which serve no purpose); (B) not declaring a nonexistent |alt| attribute for the |iframe| element; and (C) working with the DOM as a DOM instead of a string (which has a side-effect of mitigating issues like missing end tags).

    Code:
    var iframe = document.createElement("iframe");
    iframe.src = "http://domain.com/affiliate/salejs.php?amount=15&transaction=B";
    iframe.width = "400";
    iframe.height = "400";
    For every complex problem, there is an answer that is clear, simple, and wrong.


  •  

    Posting Permissions

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