Click here to Skip to main content
15,879,096 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I wrote this function that executes Javascript in the parent window, but it is not very reliable. For instance it works in www.bing.com but not in www.google.com. Any idea why?
C++
HRESULT JS_InsertInline(wstring script)
{
	VARIANT vrt			= { 0 };		
	return win2->execScript(SysAllocStringLen(script.data(), script.size()), L"javascript", &vrt);
}


Any idea why? I tried using IHTMLScriptElement, but I have no idea how to do it in C++...


Regarding AJAX, the only thing I found was this. Not much information. Are there any examples or articles on how I could make an AJAX request from withing the function?


Thank you
Posted
Updated 17-Mar-14 23:33pm
v3
Comments
[no name] 18-Mar-14 19:36pm    
What's your application? Why do you want to do this?
pestis 19-Mar-14 4:05am    
It's an extension I want to write for IE... I want to contact a REST server every X minutes. I thought of doing with AJAX would be the best option since it uses the user's cookies + that is how I would do it in a Firefox\Chrome extension.
[no name] 19-Mar-14 14:19pm    
But why a BHO when simple HTML pages will do?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900