jScript debugger error, in simple script

杀马特。学长 韩版系。学妹 提交于 2019-12-01 10:58:36

问题


I'm working on a local html file, stored on a Win7 machine and opened in IE 9. This html file uses javascript and jStorage.

However, when I run, I get the error "SCRIPT5007: Unable to get value of the property 'set': object is null or undefined." This error points to the statement $.jStorage.set("Key", "Hello");.

What am I doing wrong? I've made the html and javascript about as basic as I can, to narrow things down.

Here's the html:

<!DOCTYPE html>
<html>
    <head>
    <title>Backlog Tracker</title>
    <script src="jquery-2.1.1.min.js"></script>
    <script src="json2.js"></script>
    <script src="jstorage.min.js"></script>
    <script src="backlog.js"></script>
    </head>
    <body>
    </body>
</html>

... and, here's the script (referenced as "backlog.js" in the html):

$(document).ready(function(){
    $("body").append("<button>Try It</button>");
    $("button").click(function(){
    $.jStorage.set("Key", "Hello");
    console.log($.jStorage.get("Key"));
    });
});

As a side note, I've read other questions on SO, such as here, but nothing seems to explain this. Reference jStorage usage here, everything seems to be in order. I was originally pointed to jStorage thanks to this SO answer.


回答1:


localStorage does not work for local files in IE. It does in Chrome but not in IE.

Also IE 9 does support JSON if you have <!DOCTYPE html> and <meta http-equiv="X-UA-Compatible" content="IE=edge;chrome=1" /> in your document.

Try to run a small local web server.



来源:https://stackoverflow.com/questions/24210706/jscript-debugger-error-in-simple-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!