I've reduced the problem to its bare bones using JSFiddle: http://fiddle.jshell.net/ZuV7J/
This properly parses the simple JSON string in Firefox and Chrome, but returns an empty object (regardless of the JSON string used) in IE8, IE9 and IE10. I'm yet to try with IE11.
This happens whether or not I load Crockford's JSON2.js library.
In Internet Explorer window.event
Represents the state of an event, such as the element in which the event occurred, the state of the keyboard keys, the location of the mouse, and the state of the mouse buttons.
It cannot be assigned to.
Without var
, your code event = JSON.parse('{"var":"value"}');
tries to assign to window.event
which is not allowed.
Change to use a different variable name or prefix event with var so your code reads: var event=JSON.parse('{"var":"value"}');
简短答案:在不使用var声明本地变量的情况下,不要使用“ event”变量:-)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.