srinivas_kv80

I was facing problem to get return value from execScript() in IHTMLWindow2. I am able to run the script methods by using this method execScript(), but not able to get the return value. Could you help in solving this problem either in calling the methods in C++ programming or doing changes in my script

Re: Internet Explorer Web Development How to get return value from execScript() in IHTMLWindow2?

Lance Leonard

Not without an idea of the code in question or the environment you're running it under, no.

If you're running under Protected Mode IE, for example, you may be running into a difference between the integrity level of your application and the level of the process affected by execScript(). More details on this can be found in Understanding and Working in Protected Mode Internet Explorer.

If your not working with protected mode, it would help to see your code.

Hope this helps...

-- Lance






Re: Internet Explorer Web Development How to get return value from execScript() in IHTMLWindow2?

srinivas_kv80

Thanks for the reply.
I am calling from my C++ code a javascript method which returns an integer, so by using execScript() method can I get the return value or not Please find below the Javascript and my c++ code which is calling it.

<html>
<head>
function foo(variable){
alert(variable);
return variable;
}
</head>
<body>
</body>
</html>

We can hold of this window pointer MSHTML::IHTMLWindow2 * window.
window->execScript();
result = windowPtr->execScript(TEXT("foo(4);"), TEXT("JScript"));

The above command always returns VT_EMPTY. result is of type VARIANT.

Please let me know if there is any other way through which I can get return value from javascript.

Thanks in advance.




Re: Internet Explorer Web Development How to get return value from execScript() in IHTMLWindow2?

thenewcoder

I think there is no easy way to do this... Why not create a new element, populate that elements value with the function's return value and lastly read the elements value.

windowPtr->execScript(TEXT("var e = document.createElement('div'); e.id = 'divResult'; e.innerHTML = foo(4); document.body.appendChild(e);"), TEXT("JavaScript"));

result = windowPtr->document->getElementByID(TEXT("divResult")).innerHTML;