Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
56
rated 0 times [  63] [ 7]  / answers: 1 / hits: 19485  / 10 Years ago, thu, june 5, 2014, 12:00:00

Why does this not work?



 <input type=file id=kmlFiles2 multiple onchange=function(){alert('why does this not work')}()>


chrome gives me an error,
Uncaught SyntaxError: Unexpected token (.



Firefox tells me SyntaxError: function statement requires a name.



But this does work?



 <input type=file id=kmlFiles2 multiple onchange=alert('but this does work')>


http://jsfiddle.net/ewzyV/



I am asking because I was was trying to use and MVC framework that injects code into the onchange event.


More From » html

 Answers
71
onchange=(function(){alert('this should work')})()

[#70699] Wednesday, June 4, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
havenbilliec

Total Points: 324
Total Questions: 106
Total Answers: 94

Location: Pitcairn Islands
Member since Fri, Oct 15, 2021
3 Years ago
;