How to create a 0-border iframe?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ferris
    New Member
    • Oct 2007
    • 101

    How to create a 0-border iframe?

    Hi

    I wonder how to create a 0-border iframe with javascript,here 's my code,it works in firefox,but not in IE.

    [CODE=javascript]
    <div id="testdiv"></div>
    <script language="javas cript">
    var iframe = document.create Element("iframe ");
    iframe.setAttri bute("id","fxpl ayer");
    iframe.setAttri bute("name","fx player");
    iframe.setAttri bute("width","1 00");
    iframe.setAttri bute("height"," 100");
    iframe.setAttri bute("frameBord er","0");
    document.getEle mentById("testd iv").appendChil d(iframe);
    </script>
    [/CODE]

    thanks.
  • Ferris
    New Member
    • Oct 2007
    • 101

    #2
    is there any one can help? thanks!

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      Unfortunately, frameBorder is not supported by IE (link).

      Not sure of a workaround.

      Comment

      • Dasty
        Recognized Expert New Member
        • Nov 2007
        • 101

        #4
        I dont know, but following code shows no borders in IE6 and IE7. (can no test older versions od IE tho) - win xp

        [HTML]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
        <html>
        <head>
        <script language=javasc ript>
        function go()
        {
        var iframe = document.create Element("iframe ");
        iframe.setAttri bute("id","fxpl ayer");
        iframe.setAttri bute("name","fx player");
        iframe.setAttri bute("width","1 00");
        iframe.setAttri bute("height"," 100");
        iframe.setAttri bute("frameBord er","0");
        document.getEle mentById('testd iv').appendChil d(iframe);
        }
        </script>
        </head>
        <body onload="go();" style="backgrou nd:red;">
        <div id="testdiv"></div>
        </body>
        </html>
        [/HTML]

        Comment

        • Ferris
          New Member
          • Oct 2007
          • 101

          #5
          Originally posted by acoder
          Unfortunately, frameBorder is not supported by IE (link).

          Not sure of a workaround.
          I see, thank you acoder.

          Comment

          • Ferris
            New Member
            • Oct 2007
            • 101

            #6
            Originally posted by Dasty
            I dont know, but following code shows no borders in IE6 and IE7. (can no test older versions od IE tho) - win xp

            thank you Dasty, your code does work! and I change the code into:
            [HTML]
            <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
            <html>
            <head>
            <script language=javasc ript>
            function go()
            {
            var iframe = document.create Element("iframe ");
            iframe.setAttri bute("id","fxpl ayer");
            iframe.setAttri bute("name","fx player");
            iframe.setAttri bute("width","1 00");
            iframe.setAttri bute("height"," 100");
            iframe.setAttri bute("frameBord er","0");
            //document.getEle mentById('testd iv').appendChil d(iframe);
            document.getEle mentsByTagName( 'body')[0].appendChild(if rame);
            }
            </script>
            </head>
            <body style="backgrou nd:red;">
            <input type="button" value="test" onClick="go();" />
            <div id="testdiv"></div>
            </body>
            </html>
            [/HTML]

            it still works! I guess something wrong with my some other codes.


            Thanks for help!

            Comment

            • acoder
              Recognized Expert MVP
              • Nov 2006
              • 16032

              #7
              Originally posted by Ferris
              thank you Dasty, your code does work!
              Well, that's good. Incidentally, according to the MS website, it is supported so maybe the W3Schools one is not up-to-date.

              Comment

              • HarryAlffa
                New Member
                • Jun 2010
                • 1

                #8
                I was having difficulty with:

                menu=document.c reateElement("i frame");
                menu.setAttribu te("frameborder", "0");

                it just didn't work.

                W3School's example code used the convenience property
                iframe.frameBor der="0";
                to set the frameBorder (note the camelCase), I redid with proper camel case and it works.

                menu=document.c reateElement("i frame");
                menu.setAttribu te("frameBorder", "0");

                Comment

                Working...