gpt4 book ai didi

javascript - 兼容模式下的 Internet Explorer 9 显示错误

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:21:29 25 4
gpt4 key购买 nike

在 IE 9 中测试我的 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。我不明白。 jquery 源代码中是否存在错误或我的 js 文件中是否存在错误?我如何找到它?

我在这个领域的工作时间不长,所以请给我一些想法,我真的很感激。

提前谢谢你。

[编辑]我已经添加了完整的代码。我从中学到: http://net.tutsplus.com/tutorials/javascript-ajax/how-to-create-a-jquery-image-cropping-plug-in-from-scratch-part-ii/

我不知道要添加哪一部分。整个代码不适合 stackoverflow 的提交。说“正文限制为 3000 个字符;您输入了 42121”

[第二次编辑]我在我的 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'})

它解决了我的问题。

谢谢大家

关于javascript - 兼容模式下的 Internet Explorer 9 显示错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7077471/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com