469,276 Members | 1,734 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,276 developers. It's quick & easy.

How to create a 0-border iframe?

Ferris
101 100+
Hi

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

Expand|Select|Wrap|Line Numbers
  1. <div id="testdiv"></div>
  2. <script language="javascript">
  3.     var iframe = document.createElement("iframe");
  4.     iframe.setAttribute("id","fxplayer");
  5.     iframe.setAttribute("name","fxplayer");
  6.     iframe.setAttribute("width","100");
  7.     iframe.setAttribute("height","100");
  8.     iframe.setAttribute("frameBorder","0");
  9.  document.getElementById("testdiv").appendChild(iframe);
  10. </script>
  11.  
thanks.
Nov 10 '07 #1
7 6674
Ferris
101 100+
is there any one can help? thanks!
Nov 11 '07 #2
acoder
16,027 Expert Mod 8TB
Unfortunately, frameBorder is not supported by IE (link).

Not sure of a workaround.
Nov 11 '07 #3
Dasty
101 Expert 100+
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=javascript>
function go()
{
var iframe = document.createElement("iframe");
iframe.setAttribute("id","fxplayer");
iframe.setAttribute("name","fxplayer");
iframe.setAttribute("width","100");
iframe.setAttribute("height","100");
iframe.setAttribute("frameBorder","0");
document.getElementById('testdiv').appendChild(ifr ame);
}
</script>
</head>
<body onload="go();" style="background:red;">
<div id="testdiv"></div>
</body>
</html>
[/HTML]
Nov 11 '07 #4
Ferris
101 100+
Unfortunately, frameBorder is not supported by IE (link).

Not sure of a workaround.
I see, thank you acoder.
Nov 12 '07 #5
Ferris
101 100+
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=javascript>
function go()
{
var iframe = document.createElement("iframe");
iframe.setAttribute("id","fxplayer");
iframe.setAttribute("name","fxplayer");
iframe.setAttribute("width","100");
iframe.setAttribute("height","100");
iframe.setAttribute("frameBorder","0");
//document.getElementById('testdiv').appendChild(ifr ame);
document.getElementsByTagName('body')[0].appendChild(iframe);
}
</script>
</head>
<body style="background: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!
Nov 12 '07 #6
acoder
16,027 Expert Mod 8TB
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.
Nov 12 '07 #7
I was having difficulty with:

menu=document.createElement("iframe");
menu.setAttribute("frameborder", "0");

it just didn't work.

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

menu=document.createElement("iframe");
menu.setAttribute("frameBorder", "0");
Jun 3 '10 #8

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by I_AM_DON_AND_YOU? | last post: by
10 posts views Thread by Zack Sessions | last post: by
37 posts views Thread by Steven Bethard | last post: by
18 posts views Thread by Steven Bethard | last post: by
5 posts views Thread by Michael | last post: by
2 posts views Thread by masri999 | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.