mirror of
https://github.com/encounter/phantomjs.git
synced 2026-03-30 11:35:11 -07:00
e8380e42d7
Added CoffeeScript examples where missing, minor other fixes such as spacing standardization (2 spaces is the standard in CoffeeScript via Ruby). Also a small set of minor JS example fixes and additional comments. Fixes http://code.google.com/p/phantomjs/issues/detail?id=907
17 lines
543 B
CoffeeScript
17 lines
543 B
CoffeeScript
p = require("webpage").create()
|
|
|
|
p.onConsoleMessage = (msg) ->
|
|
console.log msg
|
|
|
|
# Calls to "callPhantom" within the page 'p' arrive here
|
|
p.onCallback = (msg) ->
|
|
console.log "Received by the 'phantom' main context: " + msg
|
|
"Hello there, I'm coming to you from the 'phantom' context instead"
|
|
|
|
p.evaluate ->
|
|
# Return-value of the "onCallback" handler arrive here
|
|
callbackResponse = window.callPhantom "Hello, I'm coming to you from the 'page' context"
|
|
console.log "Received by the 'page' context: " + callbackResponse
|
|
|
|
phantom.exit()
|