JavaScript错误"拒绝访问"在Internet explorer中
JavaScript error "Access is denied" in internet explorer
当我在IE中运行我的网页时(代码在其他浏览器中运行良好),我得到这个错误。
这是HTML代码:<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
</head>
<body>
<--- some html code --->
<iframe src='http://localhost/page1.php' style="background: transparent; overflow: hidden; height: 210px; width: 390px;" frameborder="0" />
</body>
</html>
这是page1.php
<!DOCTYPE html>
<html>
<body>
<form action="usercheck.php" method="POST">
USERNAME:<input name="uname" id="uname" type="text" maxlength="12" required/>
<input type="submit" value="Submit">
</form>
</body>
</html>
这是usercheck.php
<?php
//some php code
?>
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
</head>
<body>
<--- some html code --->
</body>
</html>
问题是,当到达usercheck.php
后点击提交按钮在page1.php
我得到错误http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js. Access is denied.
这是一个错误的图像:https://i.stack.imgur.com/diCoF.jpg。然后,我得到的错误,'$'符号没有定义(这是由于未能加载jquery库)。
编辑-我已经尝试包括jquery文件在我的服务器,但仍然是错误的到来。我还为usercheck.php尝试了以下代码:
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
/*! jQuery v1.10.1 | (c) 2005, 2013 jQuery Foundation, Inc. | jquery.org/license
//@ sourceMappingURL=jquery.min.map
//and the rest of the jquery library...
</script>
</head>
<body>
<--- some html code --->
</body>
</html>
我这次得到的错误是:https://i.stack.imgur.com/hR9aN.jpg (usercheck2.php的原始名称是rscheck.php在我的服务器)。然后,我得到的错误,'$'符号没有定义(这是由于未能加载jquery库)。如果我直接打开page1.php的内容(通过url- localhost/page1.php),那么一切都可以正常工作。
这是我使用JQuery的唯一代码:
if($("#pret").contents().text().search("NAMECHECK: NOTAVALIBLE")!=-1)
我可以排除jquery只有当我可以将此代码转换为javascript
这是一个合法的jQuery 1.10.1
错误:http://bugs.jquery.com/ticket/13980 .
使用jQuery 1.10.0
或1.10.2
,错误不再发生
尝试下载jquery.min.js
到您的服务器并从那里包含它。例如:
<script type="text/javascript" src="/jquery.min.js"></script>
.
看起来internet explorer无法访问资源:将其下载到您自己的服务器可能会解决这个问题。
这是我的问题的有效解决方案。我想要jquery的原因是我想运行这段代码:
if($("#pret").contents().text().search("NAMECHECK: NOTAVALIBLE")!=-1)
我删除了jquery库,并使用这个javascript做同样的事情:
var n=document.getElementById("pret").innerHTML.search("NAMECHECK: NOTAVALIBLE");
if(n != -1)
现在页面上没有错误,我可以做我想做的。所以这个错误是由于jquery库无法在网页中加载而导致的。但我不知道为什么即使下载jquery库在我的服务器我得到同样的错误ie。'访问被拒绝'.
原因在iframe
。当jQuery从外部主机加载到iframe时,每次当您试图在主/外部html文件中使用任何jQuery函数时,IE都会出于安全原因抛出错误。
1)上传jQuery到您的服务器,
2)或者只包含在主html文件中(不包含在iframe中)
- 视频HTML没有'无法在Internet Explorer 11上工作
- 铬:“;未捕获的语法错误:意外的标记:"
- 可以设置“;文件名"发生错误时显示的内联脚本标记的
- JS表单提交"无法使用Chrome数据保护程序加载此页面.尝试重新加载页面.调试信息:POST CISmtuK
- 检测电话窃听,即:<a href="电话:xxx">在UIWebview上
- 使用“+="操作人员
- //而不是在src=“”上使用http://"属性
- "未捕获的语法错误:意外的标记}"
- 可以<脚本类型=“;text/javascript”>window.location=“/"</
- "实例范围”;TypeScript类的getter/setter
- Javascript复选框函数:;缺少:在属性id之后"
- "“;变量未引用正确的对象
- Internet Explorer缺少占位符支持,特别是密码字段
- "日期“;AJAX请求返回的类型值未定义
- Internet Explorer中的文本换行错误
- 得到"TypeError:无法读取属性'filename'未定义的“;调用“npm start
- "无法保存此网页“;Internet Explorer 8中出现错误
- 这个Javascript出了什么问题"Internet Explorer无法打开Internet站点-操作中止
- 得到"标签“;标签在Internet Explorer 6中工作(用于单选按钮)
- "text长度"Internet Explorer中svg文本元素悬停时的更改