1

I have a function in my JavaScript file which utilises the UIevent interface. What it does is it will set the selected index value of a drop down box, and then fire an onchange event.

This function works completely fine in Google Chrome, however, in IE11, Visual Studio comes up with the error "JavaScript runtime error: Object doesn't support this action" and will not do anything.

The purpose of this function is to simulate an onchange WebForms AutoPostBack event.

JavaScript:

function changeForm() {
    var dropDown = document.getElementById("DDApplicationID");

    dropDown.selectedIndex = "1";
    var event = new UIEvent("change", {
        "view": window,
        "bubbles": true,
        "cancelable": true
    }); //JavaScript runtime error occurs here
    dropDown.dispatchEvent(event);
}

WebForms

<!-- other html and webforms code -->
<asp:DropDownList ID="DDApplicationID" AutoPostBack="true" runat="server" OnSelectedIndexChanged="ApplicationDropDown_SelectedIndexChanged">

<script type="text/javascript">
    changeForm();
</script>

As mentioned, the JavaScript code works fine with Chrome, but is throwing the runtime error on IE11. Any ideas on what is causing this issue?

RoyalSwish
  • 1,503
  • 10
  • 31
  • 57

0 Answers0