Javascript – Detecting Current Internet Explorer Security Zone

htmlinternet explorerjavascriptSecurityxmlhttprequest

Is there any method of programmatically determining the current security zone settings for Internet Explorer?

I'd like to know when my site will have the XMLHttpRequest ActiveX control blocked due to IE security policy, but before the site actually tries to create it and thus causes the yellow bar to appear up the top (saying "To help protect your security, Internet Explorer has restricted this webpage from running scripts or ActiveX controls that could access your computer.")

Thanks.

Best Answer

In IE7, you could use the following JavaScript to get some idea of whether your site is trusted or not:

window.status = "test";
if (window.status == "test")
  alert("Trusted, or local intranet");
else
  alert("Not trusted, or internet");

This is based on the fact that in IE7 and onwards, scripts can no longer set the status bar text through the window.status method in the Internet and Restricted Zones. See the Release Notes for Internet Explorer 7