[webkit-dev] The "thisObject" parameter for JSEvaluateScript
Scott Thompson
easco at mac.com
Mon Mar 24 11:40:46 PDT 2008
I'm using JavaScript core to integrate JavaScript as an embedded
scripting engine in my application.
I've gotten a lot of "stuff" working (which is a lot of fun, BTW).
I've been able to run scripts and see them manipulate objects in my
application model (windows and the like... just to see if I could) as
well as objects in the object model (in the MVC sense) of my problem
domain.
I've added a scripting menu. I want the scripts that are run through
that menu to be executed "in the scope" of the frontmost document.
That is, I would like the a script whose textual content is the word
"this" to evaluate to the document object of the frontmost document.
To that end, I'm calling JSEvaluateScript and I'm passing the
JSObjectRef for my document object as it's third parameter,
"thisObject".
Even when doing so, however, I find that within my scripts the
variable "this" still refers to the global context and not the
frontmost document. For example, I'm able to successfully evaluate
the script:
this.documents[0].addDocumentElement()
(where documents is a property I add to the global context and is
roughly equivalent to [NSApp orderedDocuments]) I would rather have
the script:
this.addDocumentElement()
do the same thing... that is JSEvaluateScript should use the document
object for "this"
Am I simply misinterpreting the purpose of the "thisObject" parameter
to JSEvaluateScript?
Scott
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.webkit.org/pipermail/webkit-dev/attachments/20080324/180a229d/attachment.html
More information about the webkit-dev
mailing list