HTML DOM Window frames 属性


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 = "https://tutorialspoint.com/html5/foo.mp4";
            divDisplay.textContent = 'Virus Deployed';
      }
   </script>
</body>
</html>

输出

在单击 ‘发射病毒’ 按钮之前 −

在单击 ‘发射病毒’ 按钮之后 −

更新于:21-12-2021

171 次浏览

启动您的 职业

通过完成课程取得认证

开始
广告
© . All rights reserved.