PhantomJS - pagesWindowName Property



The pagesWindowName property returns the names of the windows that are opened using window.open.

Syntax

Its syntax is as follows −

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

Example

Let us take an example to understand the use of pagesWindowName property.

var wpage = require('webpage').create(); 
wpage.open('http://localhost/tasks/ptitle.html', function (status) {  
   console.log(wpage. pagesWindowName); 
   phantom.exit(); 
}); 

ptitle.html

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

It will generate the following output.

page1, page2

The output gives an array of page names opened using the window.open command. If the window is closed, it is not considered.

phantomjs_webpage_module_properties.htm
Advertisements