I'm getting an error only in IE (v8, I don't know if it happens in older IE versions, but it does not occur in Chrome or Firefox) which brings me the following message when I use IE dev tool's debbuger:
Breaking on JSScript runtime error - Object Expected
Here is my affected code:
$('#deviceProfileSelection').change(function() { //affected line!!!!
// rest of my code...
});
This element #deviceProfileSelection
is defined as the following:
<select id="deviceProfileSelection">
<option value=""><?php echo getSysMessage("dropDownSelect")?></option>
<!-- and other values...-->
</select>
I've already tried defining the .change listener into a $(document).ready(function () {});
but no success at all. Any other idea?
EDIT
I was trying to include a div using a PHP decision structure, where if a condition was true, it should print a div. But, actually it wasn't printing, I mean, it wasn't printing the opening tag 'div', only the closing tag 'div'.
The browsers could interpret this error, but IE8, and this IE inability was causing the issue.
I'm getting an error only in IE (v8, I don't know if it happens in older IE versions, but it does not occur in Chrome or Firefox) which brings me the following message when I use IE dev tool's debbuger:
Breaking on JSScript runtime error - Object Expected
Here is my affected code:
$('#deviceProfileSelection').change(function() { //affected line!!!!
// rest of my code...
});
This element #deviceProfileSelection
is defined as the following:
<select id="deviceProfileSelection">
<option value=""><?php echo getSysMessage("dropDownSelect")?></option>
<!-- and other values...-->
</select>
I've already tried defining the .change listener into a $(document).ready(function () {});
but no success at all. Any other idea?
EDIT
I was trying to include a div using a PHP decision structure, where if a condition was true, it should print a div. But, actually it wasn't printing, I mean, it wasn't printing the opening tag 'div', only the closing tag 'div'.
The browsers could interpret this error, but IE8, and this IE inability was causing the issue.
Share Improve this question edited Aug 17, 2015 at 16:36 victorf asked Aug 2, 2013 at 15:16 victorfvictorf 1,0482 gold badges18 silver badges37 bronze badges 4-
3
do you have jQuery included on the page before attempting to call
$
? – jbabey Commented Aug 2, 2013 at 15:18 - 1 What version jQuery are you using? – putvande Commented Aug 2, 2013 at 15:20
- 4 please note that jQuery v2.x does not support IE8. If you have jQuery v2, you will need to use v1.x instead. – Spudley Commented Aug 2, 2013 at 15:22
- Could you show the code that is inside this function? – Adaz Commented Aug 2, 2013 at 15:23
5 Answers
Reset to default 2The problem is that you haven't added jQuery into your code at all.
Add the following inside the <head>
tag:
<script type="text/javascript" src="http://code.jquery./jquery-1.10.2.min.js"></script>
That should fix your problem.
Check the following:
- Is jQuery included when this code is executed? (I'd do an alert on
$
and see what you get) - Make sure the
deviceProfileSection
element exists.
I had a similar issue to this before with IE8, if it's the same issue, it can't find the jquery library, check your path or test it with a cdn
I tried the following code in IE8, and it works just as expected. As suggested in other answers, I used the latest version of JQuery that is patible with IE8 from the JQuery CDN. Don't use 2.x -- it does not work with older browsers. Also, make sure your change event code is located in a document.ready handler.
<html>
<head>
<title>IE8 Object Expected</title>
<script type="text/javascript" src="http://code.jquery./jquery-1.10.2.min.js"></script>
<script type="text/javascript">
$(function(){
$("#deviceProfileSelection").change(function(){
console.log("#deviceProfileSelection changed to " + $(this).find(":selected").text());
});
});
</script>
</head>
<body>
<form>
<select id="deviceProfileSelection">
<option value="">Select...</option>
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
</select>
</form>
</body>
</html>
Just so that no one repeats my mistake, since you are using jquery from an external website( src="http://code.jquery./jquery-1.10.2.min.js"), make sure your internet is working