locked
window localStorage RRS feed

  • Question

  • I'm trying use window.localStorage. (var localstorage = window.localStorage)

    And I have some questions, does the localStorage would cause the following error??

    ErrorDescription =TheMicrosoftInternet Extensionsisan internal error.

    ErrorType=0
    ErrorTypeText=Generic error
    ErrorNumber=80072EE4

    or what may cause this error??

    Thanks!

    Wednesday, October 31, 2012 6:31 AM

Answers

  • Hi,

    I think it is not caused by localstorage.

    But please note Web storage is supported in Internet Explorer 8+, Firefox, Opera, Chrome, and Safari.

    So please check the other code in the page.


    Please mark the replies as answers if they help or unmark if not.
    If you have any feedback about my replies, please contact msdnmg@microsoft.com
    Microsoft One Code Framework

    • Marked as answer by Song Tian Tuesday, November 6, 2012 10:35 AM
    Thursday, November 1, 2012 2:59 AM
  • Hi Stacy,

    Thanks for reply. So from the code you provided, it seems you've called some custom event handler functions when performing the storing and accessing to the localStorage object. Therefore, you can try comment those handler to see if the problem is caused by them. Also, when dealing with localStorage(especially for complex objects), you can can always use JSON.stringify to convert them to string before storing them into localStorage and then use JSON.parse to retrieve them back.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help. Putting communities in your palms. Launch the browser on your phone now, type aka.ms/msforums and get connected!

    • Marked as answer by Song Tian Tuesday, November 6, 2012 10:35 AM
    Friday, November 2, 2012 8:02 AM
    Moderator

All replies

  • Hi,

    I think it is not caused by localstorage.

    But please note Web storage is supported in Internet Explorer 8+, Firefox, Opera, Chrome, and Safari.

    So please check the other code in the page.


    Please mark the replies as answers if they help or unmark if not.
    If you have any feedback about my replies, please contact msdnmg@microsoft.com
    Microsoft One Code Framework

    • Marked as answer by Song Tian Tuesday, November 6, 2012 10:35 AM
    Thursday, November 1, 2012 2:59 AM

  • Hi StacyChung,

    Would you show us how you call the HTML5 localStorage API when the error you mentioned occuring? Also, in addition to the HTML5 localStorage, the Windows Store javascript app can take advantage of more other storage for storing application data such as the ApplicationData.localSettings. For more information, you can refer to the following references:


    #ApplicationData.LocalSettings | localSettings property
    http://msdn.microsoft.com/en-us/library/windows/apps/windows.storage.applicationdata.localsettings.aspx

    #Storing and retrieving state efficiently (Windows Store apps using JavaScript and HTML)
    http://msdn.microsoft.com/en-us/library/windows/apps/Hh781225.aspx

     

     


    Please remember to mark the replies as answers if they help and unmark them if they provide no help. Putting communities in your palms. Launch the browser on your phone now, type aka.ms/msforums and get connected!

    Thursday, November 1, 2012 8:01 AM
    Moderator
  • Hi, Song Tian

    Thanks your sharing.

    I will look other code in the page! Thanks!


    • Edited by StacyChung Friday, November 2, 2012 5:24 AM
    Friday, November 2, 2012 5:24 AM
  • Hi, Steven Cheng

    The code I write to use localStroage is as following

    // Muted state
            setMuted: function (muted) {
                window.localStorage['playback_muted'] = muted ? 1 : 0;
                this.onMutedStateChange(muted);
            },
    
            getMuted: function () {
                var muted = window.localStorage['playback_muted'];
                if (!muted) {
                    muted = 0;
                    this.setMuted(muted);
                }
                return (parseInt(muted, 10) == 1);
            },
    

    And also thanks your sharing for localSettings!! It would be another good tool.

    Thanks!!

    Friday, November 2, 2012 5:36 AM
  • Hi Stacy,

    Thanks for reply. So from the code you provided, it seems you've called some custom event handler functions when performing the storing and accessing to the localStorage object. Therefore, you can try comment those handler to see if the problem is caused by them. Also, when dealing with localStorage(especially for complex objects), you can can always use JSON.stringify to convert them to string before storing them into localStorage and then use JSON.parse to retrieve them back.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help. Putting communities in your palms. Launch the browser on your phone now, type aka.ms/msforums and get connected!

    • Marked as answer by Song Tian Tuesday, November 6, 2012 10:35 AM
    Friday, November 2, 2012 8:02 AM
    Moderator
  • Hi Steven Cheng:

    Thanks your reply! That helps a lot.

    May I ask why need always use JSON.stringify to convert them to string before storing them into localStorage and then use JSON.parse to retrieve them back?

    If I don't use this, would that cause any problem?

    Wednesday, November 7, 2012 5:18 AM
  • Hi Stacy,

    Thanks for your reply.

    If you do not use JSON.stringify and JSON.parse to convert javascript object into string (before storing them into HTML5 localStorage), you're relying on the underlying implementation (might be specific to browser engine) to help you persisting the objects(might have complicated structure). And if you manually convert the objects you want to store, it's much safer since localStorage is certainly be able to store plain string/text data.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help. Putting communities in your palms. Launch the browser on your phone now, type aka.ms/msforums and get connected!

    Wednesday, November 7, 2012 6:04 AM
    Moderator