HTML DOM Frame/IFrame frameBorder 屬性
定義和用法
frameBorder 屬性可設置或者返回frame/iframe 元素的frameborder 屬性值。
frameborder 屬性指定是否顯示iframe 周圍的邊框。
語法
frameObject.frameBorder=value
或者
iframeObject.frameBorder=value
或者
iframeObject.frameBorder=value
frameBorder 屬性可以是以下值:
值 | 描述 |
---|---|
1 | 开启边框(默认) |
0 | 关闭边框 |
瀏覽器支持
所有主要瀏覽器都支持frameBorder 屬性
實例
實例1
返回frameborder 屬性的值:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
</head>
<body>
<iframe id="myframe" src="http://www.w3big.com" frameborder="0">
<p>你的浏览器不支持 iframes.</p>
</iframe>
<p>这个frameborder已设置:
<script>
document.write(document.getElementById("myframe").frameBorder);
</script>
<p>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
</head>
<body>
<iframe id="myframe" src="http://www.w3big.com" frameborder="0">
<p>你的浏览器不支持 iframes.</p>
</iframe>
<p>这个frameborder已设置:
<script>
document.write(document.getElementById("myframe").frameBorder);
</script>
<p>
</body>
</html>
嘗試一下»
實例2
移除frameborder:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<script>
function removeBorder(){
document.getElementById("myframe").frameBorder="0";
}
</script>
</head>
<body>
<iframe id="myframe" src="http://www.w3big.com">
<p>你的浏览器不支持iframes。</p>
</iframe>
<br><br>
<input type="button" onclick="removeBorder()" value="移除边界">
<p><b>注意:</b> 该实例不能工作在IE浏览器。</p>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<script>
function removeBorder(){
document.getElementById("myframe").frameBorder="0";
}
</script>
</head>
<body>
<iframe id="myframe" src="http://www.w3big.com">
<p>你的浏览器不支持iframes。</p>
</iframe>
<br><br>
<input type="button" onclick="removeBorder()" value="移除边界">
<p><b>注意:</b> 该实例不能工作在IE浏览器。</p>
</body>
</html>
嘗試一下»
Frame/IFrame對象