通过 javascript 读取 IE 中的安全参数
Read security parameters in IE via javascript
我有一个用 javascript 编写的网页。我们支持的浏览器是IE 10或11。
我正在使用 ajax 到 post HTTPRequest 到我的服务器。 post 数据类型是 JSON 。所以我需要打开 "a security parameter in IE" 以将 JSON 从页面发送到服务器。所以我需要在我的 IE 中执行此操作
Internet Options -> Security -> Custom Level -> Miscallaneous ->
Access Data Sources Across Domains [Set Enable]
实际上所有客户端的互联网选项都是不同的。我想在客户端 属性 被禁用时发出警报。所以我需要在页面加载时阅读 属性。
是否可以在客户端将 IE 安全参数设为只读?
我找到了针对这种情况的解决方法。
// use XHR for understanding CORS status
var xhr = $.ajaxSettings.xhr();
var xhrStatus = "Passive";
// if CORS is enabled in IE, at pageload the function below onload function calls,
xhr.onload = function () {
var responseText = xhr.responseText;
xhrStatus = "Active";
};
// if CORS is disable in IE, at pageload, it calls onerror function instead of onload
xhr.onerror = function () {
xhrStatus = "Passive";
};
我有一个用 javascript 编写的网页。我们支持的浏览器是IE 10或11。
我正在使用 ajax 到 post HTTPRequest 到我的服务器。 post 数据类型是 JSON 。所以我需要打开 "a security parameter in IE" 以将 JSON 从页面发送到服务器。所以我需要在我的 IE 中执行此操作
Internet Options -> Security -> Custom Level -> Miscallaneous -> Access Data Sources Across Domains [Set Enable]
实际上所有客户端的互联网选项都是不同的。我想在客户端 属性 被禁用时发出警报。所以我需要在页面加载时阅读 属性。
是否可以在客户端将 IE 安全参数设为只读?
我找到了针对这种情况的解决方法。
// use XHR for understanding CORS status
var xhr = $.ajaxSettings.xhr();
var xhrStatus = "Passive";
// if CORS is enabled in IE, at pageload the function below onload function calls,
xhr.onload = function () {
var responseText = xhr.responseText;
xhrStatus = "Active";
};
// if CORS is disable in IE, at pageload, it calls onerror function instead of onload
xhr.onerror = function () {
xhrStatus = "Passive";
};