Internet Explorer 9在兼容模式下显示错误
Internet Explorer 9 in compatibility-mode shows error
在ie9中测试我的jQuery脚本时,它显示jQuery -1.6.2.js——
SCRIPT5022: Exception thrown and not caught
jquery-1.6.2.js, line 548 character 3
我的js文件以前在其他浏览器上运行没有问题——firefox 3.6, 5.0, opera 11, chromium, chrome。我不明白。是否有一个bug在jquery源或有一个bug在我的js文件?我怎么找到它?
我在这个领域工作没多久,所以请给我一些建议。
提前谢谢你。
[编辑]我已经添加了完整的代码。我学到的是:http://net.tutsplus.com/tutorials/javascript-ajax/how-to-create-a-jquery-image-cropping-plug-in-from-scratch-part-ii/
我不知道该添加哪一部分,整个代码不适合stackoverflow的提交。表示"正文限制为3000个字符;您输入了42121 "
(第二编辑)我已经使用'error'在我的ajax提交。
//jquery ajax submit for resizing
function submit(myform,e){
$n.val($image.attr('src').replace(/^[^,]*'//,''));
var mydata = myform.serialize();
$.ajax({
url: $myform.attr('action'),
cache: false,
type:$myform.attr('method'),
data: mydata,
success: function(response){
var img = $("<img />").attr('src', 'images/'+response+'?'+ e.timeStamp) //<-- img name here
.load(function() {
if (!this.complete || typeof this.naturalWidth == "undefined" || this.naturalWidth == 0) {
alert('Incorrect image.');
} else {
$("#result").html(img); //<-- put cropped img here.
}
});
},
error: function(){ //<-- error used here
$('#result').html("Err. Loading Image");
}
});
};
我找到了我的问题。IE阻止更改属性,这会导致jQuery错误。
Note: jQuery prohibits changing the type attribute on an or element and
will throw an error in all browsers. This is because the type attribute
cannot be changed in Internet Explorer."
来自http://api.jquery.com/attr,就在第一个警告通知之后。
所以我改变了前面的代码
$('input').clone()
$('<input />').attr({'type':'hidden'})
它解决了我的问题。
谢谢大家。
jQuery.error()
(其中throws
作为消息传递的参数)与AJAX调用中指定的error
处理程序完全不同。
jQuery.error()
由jQuery
内部使用(搜索"error("))。你应该调试你的代码,并按照堆栈跟踪,找出你的哪个方法调用jQuery方法是错误的。
只是猜测,但是您是否在代码中某处使用了$.error() ?如果是:请不要使用。
<edit>
但是,这个错误来自jQuery.error()。
原来的error-function是这样的:
error: function( msg ) {
throw msg;
}
你可以不使用jquery进行测试:
(function( msg ) {
throw msg;
})('errormessage');
你会得到相同的错误。
如果你不使用jQuery.error()
也许你使用一些插件使用它。你可以通过在嵌入的jquery.js之后执行以下命令来覆盖这个(有bug的?)函数:
jQuery.error=function(){}
</edit>
- 缩略图单击时图像未以模式显示
- 模式显示文本区域内容不是字符串
- 在ajax回调(safari)中调用bootstrap模式显示
- Twtitter Bootstrap模式显示事件多次触发
- 以引导模式显示表单结果
- 引导模式显示,但没有可见文本
- 无法在提交时获取引导模式显示
- 提交表单后,将引导模式显示为“谢谢”
- 使用reactjs、localStorage和state(遍历)以模式显示表中的数据
- XPages-以读取模式显示附件
- JavaScript在验证后切换模式显示
- Jquery Cookie通过模式显示/隐藏菜单
- Rails Rendering从索引页以Bootstrap模式显示
- 强制网站仅以横向模式显示
- 如何使用单一模式显示多个图像
- 链接JavaScript不工作时,Bootstrap模式显示
- 引导模式显示不会移除隐藏属性
- Google Maps API v3 + Foundation 4 Reveal模式显示不正常
- 引导模式显示和隐藏在操作中
- 将JqGrid列模式显示为日期,超链接显示NAN/NAN/NAN