Phantomjs-pageswindowname-property

提供:Dev Guides
移動先:案内検索

PhantomJS-pagesWindowNameプロパティ

pagesWindowNameプロパティは、 window.open を使用して開かれたウィンドウの名前を返します。

構文

その構文は次のとおりです-

var wpage = require('webpage').create();
wpage.pagesWindowName;

*pagesWindowName* プロパティの使用を理解するための例を見てみましょう。
var wpage = require('webpage').create();
wpage.open('http://localhost/tasks/ptitlel', function (status) {
   console.log(wpage. pagesWindowName);
   phantom.exit();
});

タイトル

<html>
   <head>
      <title>Testing PhantomJs</title>
   </head>

   <body>
      <script type = "text/javascript">
         window.onload = function() {
            window.open("http://localhost/tasks/al","page1");
            window.open("http://localhost/tasks/contentl", "page2");
         }
      </script>
      <h1>This is a test page</h1>
   </body>

</html>

次の output が生成されます。

page1, page2

出力は、window.openコマンドを使用して開かれたページ名の配列を提供します。 ウィンドウが閉じている場合、考慮されません。