0

The error I see from IE7/IE8 in Jquery v1.7.2 and v.1.7.1 - i tried both:

 SCRIPT438: Object doesn't support property or method 'apply' 

My Code:

 <form>
 <select id="stateD" OnChange="showState()">
 <option value="none" selected="selected">==========</option>
 <option value="http://www.google.com">google</option>
 <option value="http://www.yahoo.com">Yahoo</option>
 </select>
 </form>

My Javascript - I have this pasted just below the webform:

<script type="text/javascript">
 function showState(){
oStates = document.getElementById("stateD");
var jLink = $("#stateD :selected").val();
if (jLink == undefined || jLink == "none" ){ alert("Please Select a State"); }
else{ document.location.href=jLink};
 }
</script>

I'm not using 2 libraries so i don't get why its having a problem. All that is supposed to happen is you select a url from the drop down menu and it auto sends you to that url that is in the value of the option tag. Works everywhere else, not sure why IE has to be such a jerk today.

I'd post a url but i can't at the moment. its private. has anyone encountered this issue before?

Robbiegod
  • 954
  • 4
  • 14
  • 44

2 Answers2

0

Try this simple code. Adapt a your situation, of course.

<script type="text/javascript">
<!--
window.location = "http://www.google.com/"
//-->
</script>
AFetter
  • 3,355
  • 6
  • 38
  • 62
0

Only else{ document.location.href=jLink}; doesn't look fine here (because of the semicolon after }) but I'm not sure if it's causing the error and rest of your code seems fine and oStates = document.getElementById("stateD"); is not used in your function so that line is unnecessary but it's not causing the error either but as an alternative to your problem you can use native/plain javascript instead of jQuery if you think it's jquery that causing the error and here the code for your showState function

function showState(){
    oStates = document.getElementById("stateD");
    var jLink = oStates.options[oStates.selectedIndex].value;
    if (jLink == undefined || jLink == "none" )
    {
        alert("Please Select a State");
    }
    else window.location=jLink;
 }​
The Alpha
  • 143,660
  • 29
  • 287
  • 307
  • tried your script and that did not work in IE9. So i reverted back to my original one. There are alot of jquery plugins on the page, perhaps its just interference from one of those. – Robbiegod Mar 31 '12 at 00:07
  • Try this http://stackoverflow.com/questions/8245547/document-location-not-working-in-ie9. – The Alpha Mar 31 '12 at 00:12
  • I doubt that the problem is somewhere else, try to log errors. – The Alpha Mar 31 '12 at 00:15
  • thank you for your help. I think i found the issue though...Some closing brackets in another file were missing so those google analytics push statements were not complete. Apparently, that was breaking the other scripts. – Robbiegod Mar 31 '12 at 20:13