You are here: Reference > JavaScript > client-side > HTML DOM > properties > frameBorder (frame, frameset, iframe)
frameBorder property (frame, frameset, iframe)
Sets or retrieves whether the frame is surrounded by a 3-D border.
If you need to get the width of the frameBorder dynamically:
- In Firefox, Opera, Google Chrome, Safari and Internet Explorer from version 9, use the getComputedStyle method on the frame to get its computed style, then use the borderLeftWidth, borderTopWidth, borderRightWidth and borderBottomWidth properties of the computed style.
- In older Internet Explorer versions (and optionally in newer versions as well), use the clientLeft and clientTop properties of the frame's documentElement.
Note that Internet Explorer does not allow modifying the frame border after the frame has been inserted into the document. Although the value of the frameBorder property can be changed, it will not modify the appearance of the frame.
Syntax:
You can find the related objects in the Supported by objects section below.
This property is read/write.
HTML page for this property: frameBorder |
Possible values:
String that sets or retrieves the state of the border.
One of the following values:
No border is drawn. | |||||||
Default. Frame border is drawn. | |||||||
No border is drawn. | |||||||
Frame border is drawn. |
Default: 1.
Example HTML code 1:
This example illustrates the use of the frameBorder attribute:
|
|||||||
<iframe src="frame_noborder.htm" frameborder="0"></iframe> <br /><br /> <iframe src="frame_border.htm" frameborder="1"></iframe> |
|||||||
|
|||||||
Did you find this example helpful?
|
Example HTML code 2:
This example illustrates the use of the frameBorder property:
|
|||||||
<head> <script type="text/javascript"> function GetFrameBorders () { var iframes = document.getElementsByTagName ("iframe"); for (var i = 0; i < iframes.length; i++) { var frame = iframes[i]; alert ("The frameBorder property of the " + (i+1) + ". frame is: " + frame.frameBorder); } } </script> </head> <body> <iframe src="frame_noborder.htm" frameborder="0"></iframe> <br /><br /> <iframe src="frame_border.htm" frameborder="1"></iframe> <br /><br /> <button onclick="GetFrameBorders ()">Get frame borders</button> </body> |
|||||||
|
|||||||
Did you find this example helpful?
|
Example HTML code 3:
This example shows how to get the widths of frame borders:
|
|||||||
<head> <script type="text/javascript"> function GetFrameBorderWidths () { var iframes = document.getElementsByTagName ("iframe"); for (var i = 0; i < iframes.length; i++) { var frame = iframes[i]; if (window.getComputedStyle) { // all browsers, except IE before version 9 var style = window.getComputedStyle (frame, null); var leftBorder = style.borderLeftWidth; var topBorder = style.borderTopWidth; } else { // Internet Explorer before version 9 var docElem = frame.contentWindow.document.documentElement; var leftBorder = docElem.clientLeft + "px"; var topBorder = docElem.clientTop + "px"; } alert ("The left and top borders of the " + (i+1) + ". frame are: " + leftBorder + ", " + topBorder); } } </script> </head> <body> <iframe src="frame_noborder.htm" frameborder="0"></iframe> <br /><br /> <iframe src="frame_border.htm" frameborder="1"></iframe> <br /><br /> <button onclick="GetFrameBorderWidths ()">Get the widths of frame borders</button> </body> |
|||||||
|
|||||||
Did you find this example helpful?
|
Supported by objects:
Related pages:
External links:
User Contributed Comments