HTML DOM Window frames 属性
htmlweb developmentfront end technology更新于 2024/1/30 15:08:17
HTML DOM Window frames 属性返回与窗口对应的对象,表示窗口中存在的所有框架。
语法
以下是语法 −
返回当前窗口中的框架
window.frames
让我们看一个 HTML DOM Window frames 属性的示例 −
示例
<!DOCTYPE html><html>
<head>
<title>HTML DOM Window frames</title>
<style>
* {
padding: 2px;
margin:5px;
}
form {
width:70%;
margin: 0 auto;
text-align: center;
}
input[type="button"] {
border-radius: 10px;
</style
></head>
<body>
<form>
<fieldset>
<legend>HTML-DOM-Window-frames</legend>
<label>User 1:</label><iframe src="https://www.example.com"></iframe><br>
<label>User 2:</label><iframe src="https://www.example.com"></iframe><br>
<input type="button" value="Launch Virus" onclick="goToURL()">
<div id="divDisplay">
</div>
</fieldset>
</form>
<script>
var divDisplay = document.getElementById("divDisplay");
function goToURL() {
for (var i = window.frames.length - 1; i >= 0; i--)
window.frames[i].location = "http://www.tutorialspoint.com/html5/foo.mp4";
divDisplay.textContent = 'Virus Deployed';
}
</script>
</body>
</html>
输出
点击"启动病毒"按钮之前 −

点击"启动病毒"按钮之后 −

相关文章
有用资源
html 参考教程 - 该教程包含有关 html 的更多信息:https://www.cainiaomax.com/html/

