logo
down
shadow

HTML5 on iPhone Safari - data stored by localStorage does not always persist. Why?


HTML5 on iPhone Safari - data stored by localStorage does not always persist. Why?

By : Matteo Piazza
Date : January 10 2021, 01:57 PM
help you fix your problem According to Apple (https://developer.apple.com/library/archive/documentation/iPhone/Conceptual/SafariJSDatabaseGuide/Name-ValueStorage/Name-ValueStorage.html#//apple_ref/doc/uid/TP40007256-CH6-SW3), localStorage support was added in Safari 4.0.
According to Wikipedia (https://en.wikipedia.org/wiki/Safari_version_history), Safari 4.0 was added in iPhone OS 3.0.
code :


Share : facebook icon twitter icon
How do you cache javascript on iphone Safari using html5 localStorage?

How do you cache javascript on iphone Safari using html5 localStorage?


By : user2771925
Date : March 29 2020, 07:55 AM
I hope this helps . Yes, you can. (sorry for answering my own question, I thought this was an interesting solution)
I found an outline of a code example here on slide #12.
code :
<script type="text/javascript">
// .001 is the current js version
// this script assumes it is in the root web directory.
var js_file = "site_lib.001.js";
// vars to store where the file is loaded from.
var _mob_load_js = false;
var _mob_ajax_load_js = false;
{
    // if we have localStorage and the files exists there get it.
    if(window.localStorage && window.localStorage[js_file]) {
            // eval the js file.
            try{
                window.eval(window.localStorage[js_file]);

                // successfully eval'ed the code, so 
                // we don't need to download it later.
            _mob_load_js = true;
            } catch (e) { _mob_load_js = false; }
    }
    else if (window.localStorage) {
        // We have localStorage, but no cached file, so we 
        // load the file via ajax, eval it and then store 
        // the file in localStorage

        // To remove previous versions, I remove all of our localStorage,
        // This is extreme if we store other vars there.
        window.localStorage.clear();
        // standard ajax request.
        var xhr = new XMLHttpRequest();
        xhr.onreadystatechange = function() {
        if (xhr.readyState == 4) {
            // eval the js
            try {
                window.eval(xhr.responseText);
                // successfully eval'ed the code, so 
                // we don't need to download it later.
            _mob_ajax_load_js = true;
            } catch (e) { _mob_ajax_load_js = false; }

        try {
                // store the js.
            window.localStorage[js_file] = xhr.responseText;
        } catch (e) {}
        }
        else {
        return;   
        }
    };
    xhr.open("GET",js_file,true);
    xhr.send();
    }
};
</script>
<div id="sr_external_script"></div>
<script type="text/javascript">   
// We haven't loaded the js yet, so we create a script 
// tag and get the script the old fashioned way
if (!_mob_load_js && !_mob_ajax_load_js) {
    var script=document.createElement("script");
    script.type="text/javascript";
    script.src=js_file;
    document.getElementById("sr_external_script").appendChild(script);
    // add a note to the footer
    document.write('<div>loaded from server and not stored</div>');
}
else if (!_mob_load_js) {
    // add a note to the footer
    document.write('<div>loaded via ajax and stored in localStorage</div>');
}
else {
    // add a note to the footer
    document.write('<div>loaded from localStorage</div>');
}
</script>
Is there a way to persist cookies or HTML5 localStorage across WebBrowser instances on Windows Phone?

Is there a way to persist cookies or HTML5 localStorage across WebBrowser instances on Windows Phone?


By : Andres Bravo Sandova
Date : March 29 2020, 07:55 AM
Does that help I'm not sure if this is expected behaviour or not.
To get at the Isolated Storage you will need to use JS/.NET interop.
html5 localstorage error safari

html5 localstorage error safari


By : user3483740
Date : March 29 2020, 07:55 AM
seems to work fine What the issue is
The localStorage size is limited to a relatively small size (a few MB tops). In Safari this exception occurs in two cases:
Better design for data stored using HTML5 localStorage

Better design for data stored using HTML5 localStorage


By : Buddy Palumbo
Date : March 29 2020, 07:55 AM
should help you out Not exactly sure what you are looking for. Generally I use localStorage just to store stringified versions of objects that fit my application. Rather than setting up all sorts of different keys for each variable within localStore, I just dump stringified versions of my object into one key in localStorage. That way the data is the same structure whether it comes from server as JSON or I pull it from local.
You can quickly save or retrieve deeply nested objects/arrays using JSON.stringify( object) and JSON.parse( 'string from store');
Does HTML5 localStorage persist across browser instances?

Does HTML5 localStorage persist across browser instances?


By : Todor Hristov
Date : March 29 2020, 07:55 AM
this will help Local Storage is persistant in different tabs/windows when application is opened from same domain. 5MB storage per Domain is provided. LocalStrorage can be wiped only when u remove it manualy by LocalStorage.clear(); For more on info on html5 local storage please visit :LOCALSTORAGE in html5
Related Posts Related Posts :
  • Load PDF into layer offscreen
  • What is the best approach for writing unit tests for iPhone / iPad?
  • I am getting the error Wrong type argument to unary minus and Expected ';' before ':' token
  • Custom logo on top of UINavigationBar?
  • Custom UISlider Image disappearing?
  • @synthesize comma separated list
  • Xcode iPhone Programming check if a server is online
  • objective c iphone : can we view console log on device
  • What are the sizes used for the iOS application splash screen?
  • UITableViewCell with custom gradient background, with another gradient as highlight color
  • Print a copy of my app in the iPhone Simulator?
  • NSNumberFormatter, how to remove blank spaces in currency symbol
  • Google Map Street view in Iphone app
  • How can i make a link to update my iPhone application?
  • Question Related to Custom control
  • get SSL Broken pipe error when try to make push notification
  • How to store UISegmentedControle state in NSUserdefaults
  • What developer conferences/code camps would one go for mobile development?
  • How can I intercept the StoreKit "buy dialog" to make a MBProgressHUD / UIProgressView show up correctly and a
  • Is Appcelerator Titanium now banned on the iPhone?
  • Data storing in plist works in simulaor but not in device
  • UISearchDisplayController and search performance with lots of data
  • Why is my UIViewController initializer never called?
  • Can you run a blender game on an iphone or droid?
  • CGBitmapContextCreate on the iPhone/iPad
  • Problem pushing multiple view controllers onto navigation controller stack
  • addSubview like modal
  • How create UIImage from bytes?
  • UITableView section index overlaps search bar
  • iPhone Mapkit: How can I get a real business name/address from a longitude/latitude?
  • animating adding/removing layers on iPhone
  • iPhone 4.0 Beta compile for 3.1.3
  • how to implement RSA algorithm in iphone application?
  • IPhone SDK Default NSUserDefaults
  • shadow
    Privacy Policy - Terms - Contact Us © 35dp-dentalpractice.co.uk