开发者

Delphi TWebBrowser does not respond to clicking on file hyperlinks

I have TWebBrowser component (Delphi 7), and I loaded HTML from memory stream. The HTML code of the page loaded fine, the page is displayed correctly. But when I try to click on any hyperlink with addresses (href attribute value) like "file:///C:/dir/page.html", NOTHING happens. There is no error message, and the browser does not try to go to another page. The URL is 100% correct - when I load the same webpage to the same TWebBrowser instance, but from the file on hard drive, instead of from memory stream, the exactly this link works fine. Any ideas what may be wrong?


I tried to execute the following statements:

OleCheck(WebBrowser.SecurityManager.SetZoneMapping(URLZONE_INTRANET, 'about:blank', SZM_DELETE));
OleCheck(WebBrowser.SecurityManager.SetZoneMapping(URLZONE_TRUSTED, 'about:blank', SZM_DELETE));
OleCheck(WebBrowser.SecurityManager.SetZoneMapping(URLZONE_INTERNET, 'about:blank', SZM_DELETE));
OleCheck(WebBrowser.SecurityManager.SetZoneMapping(URLZONE_UNTRUSTED, 'about:blank', SZM_DELETE));
OleCheck(WebBrowser.SecurityManager.SetZoneMapping(URLZONE_LOCAL_MACHINE, 'about:blank', SZM_DELETE));
OleCheck(WebBrowser.SecurityManager.SetZoneMapping(URLZONE_LOCAL_MACHINE, 'about:blank', SZM_CREATE));

, but they did not change anything (they were executed correctly, without errors, i.e., HRESULT = S_OK all the time). I must say that the component is actually TEmbeddedWB, (it has SecurityManager property) although TWebBrowser behaves the same way - I just re-checked it.

I think about resorting to using a file in the temporary directory.


Thanks to 开发者_运维问答all, I finally worked around the problem by using the file in the temp dir.


To your question: The Internet Explorer itself is wrong

Namely, it's impossible to access local files from a website loaded from elsewhere than file:// location without changing your security settings since IE 7. The easiest workaround just as you already mentioned is to open the website from a file:// location from your local drive and then you'll get this access.

Here are some tearful articles about that:

File URI link to local folder in IE7 not working
http://blogs.msdn.com/b/freeassociations/archive/2005/05/19/420059.aspx
http://blogs.msdn.com/b/ie/archive/2005/08/15/452006.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜