Sha256: 72edc5e5bc8391b967a837bf3356c8b1a8271b13d092742314560b5ea02fa1b2

Contents?: true

Size: 739 Bytes

Versions: 21

Compression:

Stored size: 739 Bytes

Contents

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

if phantom?
  page = require('webpage').create()

  # Route "console.log()" calls from within the Page context to the main
  # Phantom context (i.e. current "this")
  page.onConsoleMessage = (msg) -> console.log(msg)

  page.onAlert = (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", (status) ->
    if status is "success"
      if page.injectJs("injectme.coffee")
        console.log "... done injecting itself!"
      else
        console.log "... 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.coffee
hooch-0.4.1 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/lib/phantom/examples/injectme.coffee
hooch-0.4.0 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/lib/phantom/examples/injectme.coffee
hooch-0.3.0 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/lib/phantom/examples/injectme.coffee
hooch-0.2.1 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/lib/phantom/examples/injectme.coffee
hooch-0.2.0 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/lib/phantom/examples/injectme.coffee
hooch-0.1.0 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/lib/phantom/examples/injectme.coffee
hooch-0.0.8 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/lib/phantom/examples/injectme.coffee
hooch-0.0.7 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/lib/phantom/examples/injectme.coffee
hooch-0.0.6 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/lib/phantom/examples/injectme.coffee
entangled-0.0.16 spec/dummy/public/node_modules/phantomjs/lib/phantom/examples/injectme.coffee
entangled-0.0.15 spec/dummy/public/node_modules/phantomjs/lib/phantom/examples/injectme.coffee
entangled-0.0.14 spec/dummy/public/node_modules/phantomjs/lib/phantom/examples/injectme.coffee
entangled-0.0.13 spec/dummy/public/node_modules/phantomjs/lib/phantom/examples/injectme.coffee
entangled-0.0.12 spec/dummy/public/node_modules/phantomjs/lib/phantom/examples/injectme.coffee
entangled-0.0.11 spec/dummy/public/node_modules/phantomjs/lib/phantom/examples/injectme.coffee
entangled-0.0.10 spec/dummy/public/node_modules/phantomjs/lib/phantom/examples/injectme.coffee
phantomjs.rb-0.0.2 vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/injectme.coffee
phantomjs.rb-0.0.2 vendor/phantomjs-1.4.1_OSX/examples/injectme.coffee
phantomjs.rb-0.0.1 vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/injectme.coffee