Options
All
  • Public
  • Public/Protected
  • All
Menu
deprecated:use

the new Automation API instead. Easier to use and more powerful.

Execute your own custom JavaScript inside the page being loaded. INPUT You can pass in either the url to a script to load, or the text of the script itself. Example: scripts:{domReady:["//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.0/jquery.js","return 'Hello, World!';"]} OUTPUT Your scripts can return data to you in the pageResponse.scriptOutput object. You can access this directly via windows._pjscMeta.scriptOutput or your script can simply return a value and it will be set as the scriptOutput (not available on external, url loaded scripts) Also, if you use the IPageRequest.renderType="script" setting, your response will be the scriptOutput itself (in JSON format) which allows you to construct your own custom API. A very powerful feature! *

IMPORTANT. The window._pjscMeta feature will be improved soon.: the Chrome usage of this feature will improved somewhat in the near future to be more robust. Existing functionality will stay, but added features are being considered. If you would like to provide feedback, or be notified directly when These changes occur, please contact Support@PhantomJsCloud.com. Webkit implementation will stay as-is.

Hierarchy

  • IScripts

Index

Properties

Optional domReady

domReady: string[]

triggers when the dom is ready for the current page. Please note that the page may (or may not) still be loading. Additionally, this event may fire multiple times if the page redirects.

Optional load

load: string[]

new for Chrome backend. (not available on WebKit). triggered when the page.load event occurs

Please note that the domReady event may or may not have fired yet. Additionally, this event may fire multiple times if the page redirects.

Optional loadFinished

loadFinished: string[]

triggers when we determine the IPageRequest has been completed. If your page is being rendered, this occurs immediately before then. IMPORTANT NOTE: Generally you do NOT want to load external scripts (url based) here, as it will hold up rendering. Consider putting your external scripts in domReady

Optional pageNavigated

pageNavigated: string[]

new for Chrome backend. (not available on WebKit). will execute scripts when your IPageRequest navigation is started. IMPORTANT NOTE: For advanced use only. This is triggered before your page starts loading, so work done by your script may not be applied properly. Consider using domReady instead. Additionally, this event may fire multiple times if the page redirects.