0

I have the following script:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $(this).find("[id$='Panel']").hide();
        $(".toggleDisplay").change(function () {
            var groupName = $(this).find(":radio").attr('name');
            var ans = $('input[name="' + groupName + '"]:radio:checked').val();
            var displaylist = ["1", "2", "3", "4", "5"];
            if (displaylist.indexOf(ans) > -1) {
                $(this).find("[id$='Panel']").show();
            } else {
                $(this).find("[id$='Panel']").hide();
            }
        });
    });
</script>

When I inserted/tested this last week, it worked fine in IE 11. Today, it stopped working. However, it still works in Chrome. The IE error I receive is: "Object doesn't support property or method 'indexOf'"

I attempted to rewrite the if statement as follows, with no luck:

if ($.inArray(ans, displayList) != -1) {}

Any suggestions?

EDIT: The issue was my browser (somehow) reverting back to rendering as IE 8. Seems that this is a company wide issue. To prevent further hiccups, is there a painless method of doing this script in IE 8-compatible code?

niclake
  • 134
  • 13
  • 2
    Are u testing in the same IE11? If so - did DOCTYPE of the document changed? Or some meta tags to emulate older IE added? – Yuriy Galanter Oct 07 '14 at 19:52
  • Yes, and no. Literally, nothing changed in the document between Friday's functional run & today's. – niclake Oct 07 '14 at 19:55

1 Answers1

3

A plausible guess is that you've somehow bumped your version of IE to emulate IE8, which doesn't support indexOf() (see Why doesn't indexOf work on an array IE8?). You can do this (accidentally or otherwise) in various ways - see this answer here: https://stackoverflow.com/a/17877416/68231.

Community
  • 1
  • 1
Ken Smith
  • 20,305
  • 15
  • 100
  • 147
  • Frick. I have no idea how, but this is what it was. Thanks. – niclake Oct 07 '14 at 19:56
  • The weirdest part is, I have no idea how it worked last week, but not today. I haven't reset my browser, and our header had tucked in it. – niclake Oct 07 '14 at 20:05