source: other-projects/FileTransfer-WebSocketPair/Themes/themebuilder/bin/phantomjs-1.9.2-macosx/examples/injectme.js@ 31525

Last change on this file since 31525 was 31525, checked in by ak19, 7 years ago

Nathan provided more stuff: Themes folder contains Sencha's Themebuilder which generates GXT Themes. It includes the .theme and generated .jar files for the project theme.

File size: 859 bytes
Line 
1// Use 'page.injectJs()' to load the script itself in the Page context
2
3if ( typeof(phantom) !== "undefined" ) {
4 var page = require('webpage').create();
5
6 // Route "console.log()" calls from within the Page context to the main Phantom context (i.e. current "this")
7 page.onConsoleMessage = function(msg) {
8 console.log(msg);
9 };
10
11 page.onAlert = function(msg) {
12 console.log(msg);
13 };
14
15 console.log("* Script running in the Phantom context.");
16 console.log("* Script will 'inject' itself in a page...");
17 page.open("about:blank", function(status) {
18 if ( status === "success" ) {
19 console.log(page.injectJs("injectme.js") ? "... done injecting itself!" : "... fail! Check the $PWD?!");
20 }
21 phantom.exit();
22 });
23} else {
24 alert("* Script running in the Page context.");
25}
Note: See TracBrowser for help on using the repository browser.