go: http://www.iitshare.com/ie8-not-use-native-json.html resolves the cause of the problem of not using native JSON in IE8
In the project to pass the JS object on the page to the background, thought can be converted to string by JSON.
| 12 |
varobj = {"a":1 "b":2, "c":3};varstr = JSON.stringify(obj); |
The above code in the Firefox,chrome test is not a problem, but in IE8 do prompt json not defined,google a bit, naturally there are other people encounter the same problem, and give a solution, share a bit, and explain why there is this problem.
Solve
First of all, the Microsoft documentation Requirements:note has been said to be very clear, translated into Chinese meaning roughly as follows: JSON is included in JScript 5.8, and in order to backwards-compatible IE8 only in document mode is "Internet Explorer 8 Standards "Only use JSCRIPTE 5.8, other times use the Jscripte 5.7 feature. Therefore, if the document mode is not declared as "Internet Explorer 8 Standards", the JSON object cannot be found.
How to declare "Internet Explorer 8 standards", according to another Microsoft document, there are two ways to achieve:
| 12 |
1. 在文档头中添加<metahttp-equiv="X-UA-Compatible" content="IE=8">2. 使用<!DOCTYPE>来声明文档 |
Add jquery under IE