我需要支持 IE7。在 IE10 开发人员工具中,我将“文档模式设置为 IE7 标准”但它仍然显示“未定义 JSON”这是我的测试 HTML 代码:
Web site: <span id="wurl"></span><br/>
Title: <span id="wtitle"></span>
<script type="text/javascript" src="http://knivesandtools.nl/2011/js/json2.js"></script>
<script type="text/javascript">
// example of what is received from server
var jsnstr = '{"url": "http://coursesweb.net/", "title": "Web Development Courses", "users": 1500}';
// parse the "jsnstr", and store the JSON object in "obj"
var obj = JSON.parse(jsnstr);
// uses the JavaScript object, adds the values from "url", and "title" in web page
document.getElementById('wurl').innerHTML = obj.url;
document.getElementById('wtitle').innerHTML = obj.title;
</script>