- PhantomJS Tutorial
- PhantomJS - Home
- PhantomJS - Overview
- PhantomJS - Environment Setup
- PhantomJS - Object
- PhantomJS - Methods
- WebPage Module
- PhantomJS - Properties
- PhantomJS - Methods
- PhantomJS - Events/Callbacks
- PhantomJS - Child Process Module
- File System Module
- PhantomJS - Properties
- PhantomJS - Methods
- System Module
- PhantomJS - Properties
- Web Server Module
- PhantomJS - Properties
- PhantomJS - Methods
- Miscellaneous
- Command Line Interface
- PhantomJS - Screen Capture
- PhantomJS - Page Automation
- PhantomJS - Network Monitoring
- PhantomJS - Testing
- PhantomJS - REPL
- PhantomJS - Examples
- PhantomJS Useful Resources
- PhantomJS - Quick Guide
- PhantomJS - Useful Resources
- PhantomJS - Discussion
PhantomJS - ownsPages Property
The ownsPages property checks if a page opened by the webpage is its child page or not. Accordingly, it either returns true or false.
Syntax
Its syntax is as follows −
var wpage = require('webpage').create(); wpage.ownsPages
Example
Let us take an example to understand the use of ownsPages property.
var wpage = require('webpage').create(); wpage.open('http://localhost/tasks/page1.html', function (status) { console.log(wpage.ownsPages); phantom.exit(); });
page1.html
<html> <head> <title>Testing PhantomJs</title> </head> <body> <script type = "text/javascript"> console.log('welcome to cookie example'); document.cookie = "username = Roy; expires = Thu, 22 Dec 2017 12:00:00 UTC"; window.onload = function() { console.log("page is loaded"); window.open("http://localhost/tasks/a.html","page1"); } </script> <h1>This is a test page</h1> </body> </html>
The above program generates the following output.
True
phantomjs_webpage_module_properties.htm
Advertisements
To Continue Learning Please Login
Login with Google