IE8兼容模式下的javascript错误
我有以下 jQuery 代码,可以在 IE8、FF 中正常工作,但在 IE8 comp 模式下,它会给出此错误
网页错误详细信息
用户代理:Mozilla/4.0(兼容;MSIE 8.0;Windows NT 5.1;Trident/4.0;.NET CLR 2.0)。 50727;.NET CLR 3.5.21022;.NET CLR 3.5.30729; 时间戳:2010 年 10 月 29 日星期五 22:12:03 UTC
消息:对象不支持此属性或方法 线路:162 字符:44 代码:0
这是第 162 行
$(this).attr('onChange', function(iii,vvv){return vvv.replace('_','');});
这是完整的脚本
<script type="text/javascript" language="javascript">
$(document).ready(function(){
$("select[name^=SELECT___]").each(function(){
$(this).attr('onChange', function(iii,vvv){return vvv.replace('_','');});
});
$("a[href^='javascript:change_option']").each(function(){
$(this).attr('href', function(ii,vv){return vv.replace('_','');});
});
});
</script>
是什么导致了这个错误?还有其他方法可以做我想做的事吗?
我需要做的是将页面上以下代码的每个实例中的“change_option”更改为“changeoption”,也许有更好的方法。
这是 HTML 代码。我无权访问此 html 代码
编辑:
<select onChange="change_option('SELECT___100E___7',this.options[this.selectedIndex].value)" name="SELECT___100E___7">
这是文档声明。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
I have the following jQuery code that works fine in IE8, FF but in IE8 comp mode it gives this error
Webpage error details
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; Creative AutoUpdate v1.30.00)
Timestamp: Fri, 29 Oct 2010 22:12:03 UTC
Message: Object doesn't support this property or method
Line: 162
Char: 44
Code: 0
Here is line 162
$(this).attr('onChange', function(iii,vvv){return vvv.replace('_','');});
Here is the full script
<script type="text/javascript" language="javascript">
$(document).ready(function(){
$("select[name^=SELECT___]").each(function(){
$(this).attr('onChange', function(iii,vvv){return vvv.replace('_','');});
});
$("a[href^='javascript:change_option']").each(function(){
$(this).attr('href', function(ii,vv){return vv.replace('_','');});
});
});
</script>
What is causing this error? Is there another way to do what I want to do?
What I need to do is change the "change_option" to "changeoption" in each instance of the following code on the page, Perhaps there is a better way of doing it.
Here is the HTML code. I do not have access to this html code
EDIT:
<select onChange="change_option('SELECT___100E___7',this.options[this.selectedIndex].value)" name="SELECT___100E___7">
This is the doc declaration.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许。为什么不能只创建changeoption 的别名(假设您已经定义了该函数)?
Perhaps. Why can't you just create an alias of changeoption (assuming you have defined the function)?