热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

SCRIPT5:在xmlhttprequest上,IE9拒绝访问。-SCRIPT5:AccessisdeniedinIE9onxmlhttprequest

varxhttpnewXMLHttpRequest();xhttp.open(GET,foo.xml,false);F12popsback:SCRIPT5:Acces
var xhttp=new XMLHttpRequest();
xhttp.open('GET', 'foo.xml', false);

F12 pops back: SCRIPT5: Access is denied. on Line 95, which is the xhttp.open line.

F12弹出:SCRIPT5:访问被拒绝。第95行,就是xhttp。开放的线。

My Javascript seems well-formed, and Firefox does what I think it should.

我的Javascript看起来很好,而Firefox做了我认为应该做的事情。

I've read a lot of questions very similar to this one, so I've checked out the Same Origin Policy, but I can't see how it'd apply considering foo.xml is in the same directory as the html file. I opened up the scripting permissions on my local intranet, and told McAfee to take a five-minute break, just to be sure. I even tried running IE as admin, so this can't really be a permissions issue can it? Why else would IE be denied access to a local file?

我已经读了很多类似于这个的问题,所以我检查了同源策略,但是我看不出它是如何应用于foo的。xml位于与html文件相同的目录中。我打开了本地内部网的脚本权限,并告诉McAfee休息五分钟,只是为了确定。我甚至尝试运行IE作为admin,所以这不是一个权限问题吗?为什么IE会被拒绝访问本地文件?

11 个解决方案

#1


13  

Maybe you like to check the links below:

也许你想看看下面的链接:

  • Making cross domain Javascript requests using XMLHttpRequest or XDomainRequest
  • 使用XMLHttpRequest或XDomainRequest进行跨域Javascript请求。
  • XMLHttpRequest – Mozilla Developer Network
  • XMLHttpRequest - Mozilla开发者网络。
  • A good summary of the jQuery x-domain requests
  • 对jQuery x域请求的一个很好的总结。
  • Which browser supports x-domain?
  • 浏览器支持x-domain ?

#2


5  

You likely have a Mark-of-the-Web on the local file. See http://blogs.msdn.com/b/ieinternals/archive/2011/03/23/understanding-local-machine-zone-lockdown-restricted-this-webpage-from-running-scripts-or-activex-controls.aspx for an explanation.

您可能在本地文件上有一个标记。请参见http://blogs.msdn.com/b/ieinternals/archive/2011/03/23/了解本地机器-zone- from- runningscripts -or-activex- activex控件。

#3


5  

This example illustrate how to use AJAX to pull resourcess from any website. it works across browsers. i have tested it on IE8-IE10, safari, chrome, firefox, opera.

这个例子说明了如何使用AJAX从任何网站获取资源。它可以在浏览器。我已经在IE8-IE10, safari, chrome, firefox, opera上测试过了。

if (window.XDomainRequest) xmlhttp = new XDomainRequest();
else if (window.XMLHttpRequest) xmlhttp = new XMLHttpRequest();
else xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");

xmlhttp.open("GET", "http://api.hostip.info/get_html.php", false);
xmlhttp.send();

hostipInfo = xmlhttp.responseText.split("\n");
var IP = false;
for (i = 0; hostipInfo.length >= i; i++) {
    if (hostipInfo[i]) {

        ipAddress = hostipInfo[i].split(":");
        if (ipAddress[0] == "IP") {
            IP = ipAddress[1];
        }
    }
}
return IP;

#4


2  

This error message (SCRIPT5: Access is denied.) can also be encountered if the target page of a .replace method is not found (I had entered the page name incorrectly). I know because it just happened to me, which is why I went searching for some more information about the meaning of the error message.

这个错误消息(SCRIPT5:访问被拒绝)也可以在a .replace方法的目标页面中遇到(我错误地输入了页面名称)。我知道,因为它刚刚发生在我身上,所以我去寻找更多关于错误信息含义的信息。

#5


1  

On IE7, IE8, and IE9 just go to Settings->Internet Options->Security->Custom Level and change security settings under "Miscellaneous" set "Access data sources across domains" to Enable.

在IE7、IE8和IE9上,只需进入设置->网络选项->安全->自定义级别,并在“杂项”设置“跨域访问数据源”下更改安全设置。

#6


1  

Most likely, you need to have the Javascript served over SSL.

最可能的情况是,您需要将Javascript服务于SSL。

Source: https://www.parse.com/questions/internet-explorer-and-the-Javascript-sdk

来源:https://www.parse.com/questions/internet-explorer-and-the-Javascript-sdk

#7


0  

I think that the issue is that the file is on your local computer, and IE is denying access because if it let scripts have access to files on the comp that the browser is running on, that would be a HUGE security hole.
If you have access to a server or another comp that you could use as one, maybe you could try putting the files on the that, and then running the scripts as you would from a website.

我认为问题在于文件在本地计算机上,IE拒绝访问,因为如果它允许脚本访问浏览器正在运行的comp上的文件,那将是一个巨大的安全漏洞。如果您可以访问服务器或其他可以使用的comp,那么您可以尝试将这些文件放到该服务器上,然后像从网站上那样运行脚本。

#8


0  

Probably you are requesting for an external resource, this case IE needs the XDomain object. See the sample code below for how to make ajax request for all browsers with cross domains:

可能您正在请求外部资源,这种情况下需要XDomain对象。请参阅下面的示例代码,了解如何对跨域的所有浏览器发出ajax请求:

Tork.post = function (url,data,callBack,callBackParameter){
    if (url.indexOf("?")>0){
        data = url.substring(url.indexOf("?")+1)+"&"+ data;
        url = url.substring(0,url.indexOf("?"));
    }
    data += "&randomNumberG=" + Math.random() + (Tork.debug?"&debug=1":"");
    var xmlhttp;
    if (window.XDomainRequest)
    {
        xmlhttp=new XDomainRequest();
        xmlhttp.Onload= function(){callBack(xmlhttp.responseText)};
    }
    else if (window.XMLHttpRequest)
        xmlhttp=new XMLHttpRequest();
    else
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    xmlhttp.Onreadystatechange=function()
    {
        if (xmlhttp.readyState==4 && xmlhttp.status==200){
            Tork.msg("Response:"+xmlhttp.responseText);
            callBack(xmlhttp.responseText,callBackParameter);
            Tork.showLoadingScreen(false);
        }
    }
    xmlhttp.open("POST",Tork.baseURL+url,true);
    xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
    xmlhttp.send(data);
}

#9


0  

I had faced similar issue on IE10. I had a workaround by using the jQuery ajax request to retrieve data:

我在IE10上也遇到过类似的问题。我使用jQuery ajax请求来检索数据:

$.ajax({
    url: YOUR_XML_FILE
    aync: false,
    success: function (data) {   
        // Store data into a variable
    },
    dataType: YOUR_DATA_TYPE,
    complete: ON_COMPLETE_FUNCTION_CALL
});

#10


-1  

  $.ajax({
        url: '//freegeoip.net/json/',
        type: 'POST',
        dataType: 'jsonp',
        success: function(location) {
            alert(location.ip);
        }
    });

This code will work https sites too

这段代码也将使用https站点。

#11


-3  

Open the Internet Explorer Developer Tool, Tools -> F12 developer tools. (I think you can also press F12 to get it)

打开Internet Explorer开发工具,工具——> F12开发工具。(我认为你也可以按F12来得到它)

Change the Document Mode to Standards. (The page should be automatically refresh, if you change the Document Mode)

将文档模式更改为标准。(如果您更改了文档模式,页面应该自动刷新)

Problem should be fixed. Enjoy

问题应该是固定的。享受


推荐阅读
author-avatar
仔仔衰才_887
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有