On Sun, Jan 23, 2011 at 7:55 PM, Aaron C <[email protected]> wrote:
> this.navigator = {
> userAgent : "MSIE"
> };
> this.document = {
> documentElement : {}
> };
>
>
Maybe something like...
a) Create a new Object:
Local<Object> obj( Object::New() );
b) Add that object to the global object:
Local<Object> global( v8::Context::GetCurrent()->Global() );
global->Set( String::New("document"), obj );
now your global object has a plain object called 'document'. You would
repeat this for the navigator item, and insert the userAgent and
documentElements as children of the navigator/document.
Or, even easier:
Since you're using the sample shell, you have the load() function: simply
write the above JS code into a file, and load() that file before proceeding
with the other scripts.
>
> This, for example, throws an exception:
>
> global->Set(String::New("window"), global);
>
That should work just fine - i do that same thing in some code to give my
global object a name.
> if (!window) this.window = this;
>
You can do this to avoid that error:
if( 'undefined' === typeof this.window ) this.window = this;
--
----- stephan beal
http://wanderinghorse.net/home/stephan/
--
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users