Closed PrototypeAlex closed 10 years ago
That's better, thx! :+1:
Concerning this.url
: Are you sure that this
is bound to the page
instance?
Yup, but how I found that out is pretty gross, not my proudest moment.... :grinning:
page.open "http://google.com/", (status) ->
console.log Object.getOwnPropertyNames(this)
Outputs:
objectName,title,frameTitle,content,frameContent,url,frameUrl,loading,loadingProgress,canGoBack,canGoForward,plainText,framePlainText,libraryPath,offlineStoragePath,offlineStorageQuota,viewportSize,paperSize,clipRect,scrollPosition,navigationLocked,customHeaders,zoomFactor,cookies,windowName,pages,pagesWindowName,ownsPages,framesName,frameName,framesCount,focusedFrameName,destroyed(QObject*),destroyed(),deleteLater(),initialized(),loadStarted(),loadFinished(QString),javaScriptAlertSent(QString),javaScriptConsoleMessageSent(QString),javaScriptErrorSent(QString,QString),resourceRequested(QVariant,QObject*),resourceReceived(QVariant),resourceError(QVariant),resourceTimeout(QVariant),urlChanged(QUrl),navigationRequested(QUrl,QString,bool,bool),rawPageCreated(QObject*),closing(QObject*),openUrl(QString,QVariant,QVariantMap),release(),close(),evaluateJavaScript(QString),render(QString,QVariantMap),render(QString),renderBase64(QByteArray),renderBase64(),injectJs(QString),_appendScriptElement(QString),_getGenericCallback(),_getFilePickerCallback(),_getJsConfirmCallback(),_getJsPromptCallback(),_uploadFile(QString,QStringList),sendEvent(QString,QVariant,QVariant,QString,QVariant),sendEvent(QString,QVariant,QVariant,QString),sendEvent(QString,QVariant,QVariant),sendEvent(QString,QVariant),sendEvent(QString),setContent(QString,QString),getPage(QString),childFramesCount(),childFramesName(),switchToFrame(QString),switchToChildFrame(QString),switchToFrame(int),switchToChildFrame(int),switchToMainFrame(),switchToParentFrame(),switchToFocusedFrame(),currentFrameName(),setCookies(QVariantList),cookies(),addCookie(QVariantMap),deleteCookie(QString),clearCookies(),canGoBack(),goBack(),canGoForward(),goForward(),go(int),reload(),stop()
Which matches the webpage interface.
There's probably a much nicer way to do that, but it's unbeknown to me.
Cheers
Haha, nice. I guess, there is no other way unless the Webpage constructor is exposed somewhere and you could check for it via instanceof
.
The phantomjs api is pretty rotten imho. There are some scary quirks ^^.
Super small change, but I found the api docs showing what the webpage instance has access to handy for reference, so I've added the link to the phantom.js webpage module and bound url to this in the example.