Sha256: c25aaa0a4676d143620ec4f561e5ddf5521198e84290b7bc7f00383657535250

Contents?: true

Size: 859 Bytes

Versions: 21

Compression:

Stored size: 859 Bytes

Contents

// Use 'page.injectJs()' to load the script itself in the Page context

if ( typeof(phantom) !== "undefined" ) {
    var page = require('webpage').create();

    // Route "console.log()" calls from within the Page context to the main Phantom context (i.e. current "this")
    page.onConsoleMessage = function(msg) {
        console.log(msg);
    };
    
    page.onAlert = function(msg) {
        console.log(msg);
    };
    
    console.log("* Script running in the Phantom context.");
    console.log("* Script will 'inject' itself in a page...");
    page.open("about:blank", function(status) {
        if ( status === "success" ) {
            console.log(page.injectJs("injectme.js") ? "... done injecting itself!" : "... fail! Check the $PWD?!");
        }
        phantom.exit();
    });
} else {
    alert("* Script running in the Page context.");
}

Version data entries

21 entries across 19 versions & 3 rubygems

Version Path
hooch-0.4.2 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/lib/phantom/examples/injectme.js
hooch-0.4.1 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/lib/phantom/examples/injectme.js
hooch-0.4.0 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/lib/phantom/examples/injectme.js
hooch-0.3.0 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/lib/phantom/examples/injectme.js
hooch-0.2.1 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/lib/phantom/examples/injectme.js
hooch-0.2.0 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/lib/phantom/examples/injectme.js
hooch-0.1.0 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/lib/phantom/examples/injectme.js
hooch-0.0.8 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/lib/phantom/examples/injectme.js
hooch-0.0.7 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/lib/phantom/examples/injectme.js
hooch-0.0.6 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/lib/phantom/examples/injectme.js
entangled-0.0.16 spec/dummy/public/node_modules/phantomjs/lib/phantom/examples/injectme.js
entangled-0.0.15 spec/dummy/public/node_modules/phantomjs/lib/phantom/examples/injectme.js
entangled-0.0.14 spec/dummy/public/node_modules/phantomjs/lib/phantom/examples/injectme.js
entangled-0.0.13 spec/dummy/public/node_modules/phantomjs/lib/phantom/examples/injectme.js
entangled-0.0.12 spec/dummy/public/node_modules/phantomjs/lib/phantom/examples/injectme.js
entangled-0.0.11 spec/dummy/public/node_modules/phantomjs/lib/phantom/examples/injectme.js
entangled-0.0.10 spec/dummy/public/node_modules/phantomjs/lib/phantom/examples/injectme.js
phantomjs.rb-0.0.2 vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/injectme.js
phantomjs.rb-0.0.2 vendor/phantomjs-1.4.1_OSX/examples/injectme.js
phantomjs.rb-0.0.1 vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/injectme.js