javascript error in IE8 compatibitlity mode

醉酒当歌 提交于 2019-12-25 00:30:01

问题


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">

回答1:


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.

Perhaps. Why can't you just create an alias of changeoption (assuming you have defined the function)?

var change_option = changeoption;


来源:https://stackoverflow.com/questions/4056326/javascript-error-in-ie8-compatibitlity-mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!