2
votes

I am making a Windows 8 Phone app using HTML 5 project template.

I have download jquery-1.9.1.js using nuget and also have downloaded jquery.mobile-1.2.0.js from here and have added them to my project.

Now I am using the following code, I am trying to use localStorage, my below code works with Chrome and Firefox, but not with IE 10.

Common.js

$(document).ready(function(){
    alert("jquery started");
    localStorage.selectedCategory = "cc";
    alert("After assignment");
    alert(localStorage.selectedCategory);
})

When i run this in IE 10 I get the following error messages in console, and only my first alert "jquery started" is shown, the rest of the alerts are not shown.

SCRIPT5007: Unable to get property 'msie' of undefined or null reference jquery.mobile-1.2.0.js, line 2536 character 5

SCRIPT5007: Unable to set property 'selectedCategory' of undefined or null reference common.js, line 3 character 2

enter image description here

The moment I comment out the localStorage code, all alerts are shown, but still one of the error remains in the console.

SCRIPT5007: Unable to get property 'msie' of undefined or null reference jquery.mobile-1.2.0.js, line 2536 character 5

enter image description here

I just dont seem to understand the problem, please help me out on this.

EDIT : My html code :

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <link rel="stylesheet" type="text/css" href="/html/css/phone.css" />
        <title>Interview QA</title>
        <script type="text/javascript" src="../Scripts/jquery-1.9.1.js"></script>
        <script type="text/javascript" src="../Scripts/jquery.mobile-1.2.0.js"></script>
        <script type="text/javascript" src="../Scripts/Custom/common.js"></script>
    </head>
    <body>
      <div id="header"></div>
      <div id="footer"></div>
      <div></div>
    </body>
</html>
3
Isn't this a duplicate of your post here: stackoverflow.com/questions/14795286/…Steve Wellens

3 Answers

2
votes

You probably need the correct doctype:

<!doctype html>
2
votes

I too got the same error. But when I replaced "localStorage" with the keyword "Storage", it worked in ie10. Modify your your code like this and try:

$(document).ready(function(){
    alert("jquery started");
    Storage.selectedCategory = "cc";
    alert("After assignment");
    alert(Storage.selectedCategory); })

Update: But this is not equivalent to local storage, because this get cleared when the page is refreshed. When further explored found that localStorage is not working with file:// protocol in ie10. However if you host your page under a web server(IIS/Tomcat etc.,) and access it through http:// protocol, localStorage works just fine in ie10.

0
votes

jquery have removed $.browser and browser checking code so please use jquery migrate.js which will avoid this issue.

http://blog.jquery.com/2013/01/15/jquery-1-9-final-jquery-2-0-beta-migrate-final-released/