How to read variable created in global context?
Posted: Wed Jan 24, 2018 6:16 pm
I'm creating a variable like this:
var globalContext : ICefV8Value = nil; // global variable
procedure GlobalCEFApp_OnContextCreated(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context);
var
str : ICefV8Value;
begin
globalContext:=context.Global;
str:=TCefv8ValueRef.NewString('Hello world!');
globalContext.SetValueByKey('myval',str,V8_PROPERTY_ATTRIBUTE_NONE);
end;
When I open DevTools and in Console check "myval" variable I got "Hello world!" string.
That means that "myval" was created succesfully.
Than I try to read this value inside Delphi app this way:
function myFunc;
var myval : ICEFv8Value;
begin
myval:=globalContext.GetValueByKey('myval');
// the "myval" is nil !
end;
Unfortunaelly I got "nil". Of course "myFunc" is fired after the variable "myval" is created (in Console I can read it).
What is wrong ?
var globalContext : ICefV8Value = nil; // global variable
procedure GlobalCEFApp_OnContextCreated(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context);
var
str : ICefV8Value;
begin
globalContext:=context.Global;
str:=TCefv8ValueRef.NewString('Hello world!');
globalContext.SetValueByKey('myval',str,V8_PROPERTY_ATTRIBUTE_NONE);
end;
When I open DevTools and in Console check "myval" variable I got "Hello world!" string.
That means that "myval" was created succesfully.
Than I try to read this value inside Delphi app this way:
function myFunc;
var myval : ICEFv8Value;
begin
myval:=globalContext.GetValueByKey('myval');
// the "myval" is nil !
end;
Unfortunaelly I got "nil". Of course "myFunc" is fired after the variable "myval" is created (in Console I can read it).
What is wrong ?