BlueGit

blue-star danique-bot

Files

danique-bot / node_modules / phantomjs-prebuilt / lib / phantom / examples / pagecallback.js

pagecallback.js

Import template
timfa Tim · pushed by timfa · 4 years ago
c788ad20 History
pagecallback.js 623 B Download Raw
1"use strict";
2var p = require("webpage").create();
3
4p.onConsoleMessage = function(msg) { console.log(msg); };
5
6// Calls to "callPhantom" within the page 'p' arrive here
7p.onCallback = function(msg) {
8 console.log("Received by the 'phantom' main context: "+msg);
9 return "Hello there, I'm coming to you from the 'phantom' context instead";
10};
11
12p.evaluate(function() {
13 // Return-value of the "onCallback" handler arrive here
14 var callbackResponse = window.callPhantom("Hello, I'm coming to you from the 'page' context");
15 console.log("Received by the 'page' context: "+callbackResponse);
16});
17
18phantom.exit();