Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
41
rated 0 times [  48] [ 7]  / answers: 1 / hits: 51423  / 12 Years ago, fri, june 29, 2012, 12:00:00

In the IE developer (F12) console, I've managed to get my pages to run without errors; all but one!




SCRIPT1002: Syntax error

mypage.php, line 1 character 6




I am using IE9. Whats it's problem?



This is my code:



<!DOCTYPE html>
<head>
<script type='text/javascript' src='/files/jquery-1.7.2.min.js'></script>
<script type=text/javascript>
$(document).ready(function() {
$(#donateButton).click(function() {
alert('hey');
});
});
</script>
</head>
<body>
<a href=javascript:void(); id=donateButton>asdsadasd</a>
</body>


When I click on #donateButton an error is produced. However, when I change javascript:void() to # then no error occurs any more. Why?


More From » html

 Answers
74

WAIT... does IE9 not like <a href=javascript:void(); id=donateButton> ?? It seems thats the problem..?

Comment by Chud37




Yes, that is the problem. void is an operator, not a function. Use javascript:void 0 , javascript:void(0) or #. Even better, add event.preventDefault() to your function:



$('#donateButton').click(function(ev) {
ev.preventDefault();
alert('hello');
});

[#84566] Thursday, June 28, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
nikokorbinm

Total Points: 744
Total Questions: 126
Total Answers: 104

Location: Jersey
Member since Fri, Oct 1, 2021
3 Years ago
;