- 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 - settings Property
This property will give the settings of the webpage when page.open method is used. Once the page is loaded, the changes in the settings properties will not create any impact. It allows you to read /change the required settings.
Following are the values stored in the settings objects −
XSSAuditingEnabled − False. It has default value to false and it defines whether the load request should be monitored for cross-domains scripts.
javascriptCanCloseWindows − True. To activate/deactivate closing of windows opened from a page.
javascriptCanOpenWindows − True. To activate/deactivate opening of windows from a page.
javascriptEnabled − True. To enable/disable javascript. By default, it is true.
loadImages − True. To activate/deactivate loading of images. By default, it is set to true.
localToRemoteUrlAccessEnabled − True. It defines whether locally if remote URL’s can be accessed or not. By default, it is true.
userAgent − Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/538.1. Gives the details of the userAgent when the pages are requested from the server.
webSecurityEnabled − True. Defines if security of web should be enabled or not. It is true by default.
resourceTimeout − (in milli-secs) defines the timeout after which any resource requested will stop trying and proceed with other parts of the page.onResourceTimeout callback will be called on timeout.
Syntax
Its syntax is as follows −
var wpage = require('webpage').create(); wpage.settings
Example
Let us take an example to understand the use of settings property.
var wpage = require('webpage').create(); wpage.open('http://localhost/tasks/page1.html', function (status) { console.log(JSON.stringify(wpage.settings)); phantom.exit(); });
It will generate the following output.
{"XSSAuditingEnabled":false,"javascriptCanCloseWindows":true,"javascriptCanOpen Windows":true,"javascriptEnabled":true,"loadImages":true,"localToRemoteUrlAccess Enabled":false,"userAgent":"Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/538.1 (KHTML, like Gecko) PhantomJS/2.1.1 Safari/538.1","webSecurityEnabled":true}
To Continue Learning Please Login
Login with Google