Until now, the easiest way to communicate with your host application from an embedded WebBrowser script was through the use of the window.status property. Assigning a value to it would cause the TWebBrowser.OnStatusTextChange event to fire in your application. Unfortunately...
Microsoft decided that this is a security vulnerability which they needed to control. So, from Internet Explorer 7, Microsoft has added a new security policy which prevents javascript from changing the status bar text. You can lift this protection from the Internet Options dialog (IE menu -> Tools -> Internet Options -> Security -> Custom Level -> Scripting -> Allow status bar updates via script), but you dont want to ask this from the user of your program now would you?
Quick and dirty fix
The quick and dirty fix is simple. If you dont care about the title of the webpage which is displayed in your embedded webbrowser, just use the document.title property to communicate with your host!
If the title property is changed from javascript, the TWebBrowser.OnTitleChange event will fire.
One note: previously when using the window.status method, you would have to clear the status string right after you changed it:
window.status="Hello from javascript";
window.status="";However, this does not work when using the window.title method. Just set the title and leave it:
document.title="Hello from javascript";A better solution?
A better solution would be something that didn't require messing around with the title of the webpage. For example, modifying the security settings from your applications code. And with that I’m not saying modifying the registry through code, that would be a too dirty hack, with lots of side effects. If there is a way, it should be done through the IE security API. I looked around the IE security API but unfortunately could not find an easy way to modify this window.status protection setting. If anyone knows a way to do it, please notify me about it. I would be eager to learn how to do this!
Deze reactie is verwijderd door een blogbeheerder.
BeantwoordenVerwijderenHi!
BeantwoordenVerwijderenJust make use of window.external
http://www.delphidabbler.com/articles?article=22&part=1
wbr