views:

42

answers:

1

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"&gt;
+1  A: 

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;
Chetan Sastry
I am not following you on this. I don't see how this is going to call the changeoption function instead of the change_option function. Can you explain it a little more?
Functions are like any other variables in javascript. It is the same thing as doing `var b=10; var a=b; alert(a)` Of course it is going to alert the value of a, but it has the same value as b. Or maybe I have completely misunderstood your question.
Chetan Sastry
To clarify, right now the function that is called when there is a change in each select box with name beginning with SELECT___ is this change_option(xxxxxx,xxxxxx) I want the function called to be this changeoption (xxxxxx,xxxxxx). now i tried doing it with the replace function you see above but that only worked in FF and IE8 but gave a javascipt error in IE8 comp mode. I hope that is making more sense.