【问题标题】:Why is this Javascript not being compatible with Google Chrome?为什么此 Javascript 与 Google Chrome 不兼容?
【发布时间】:2011-09-06 12:54:57
【问题描述】:

每次我尝试在 Google Chrome 中查看我的网页时,我都会收到以下信息:

XMLHttpRequest 无法加载文件:tickercontent.txt?bustcache=1306951376114。仅 HTTP 支持跨源请求。 ajaxticker.js:63Uncaught 错误:NETWORK_ERR:XMLHttpRequest 异常 101

页面上什么也没有显示。

ajax_ticker.prototype.getXMLfile=function(){
    this.ajaxobj=createAjaxObj() //recreate Ajax object (IE seems to require it)
    if (this.ajaxobj){
        var instanceOfTicker=this
        var url=this.xmlfile+"?bustcache="+new Date().getTime()
        this.ajaxobj.onreadystatechange=function(){instanceOfTicker.initialize()}
        this.ajaxobj.open('GET', url, true)
        this.ajaxobj.send(null)
    }
}

第 63 行将是“this.ajaxobj.send(null)”

【问题讨论】:

  • Cross origin requests are only supported for HTTP - 因此没有本地系统文件访问权限,也没有 HTTPS 访问权限。

标签: javascript google-chrome syntax-error identifier


【解决方案1】:

行为是设计使然。 chromium issue 47416 讨论了可能的解决方案。

目前唯一的解决方法是使用 --allow-file-access-from-files 启动 chrome

【讨论】:

    猜你喜欢
    • 2018-12-09
    • 2014-12-31
    • 1970-01-01
    • 1970-01-01
    • 2013-10-21
    • 2017-10-08
    • 2014-11-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多