YUI 2: Storage Utility - Why aren't key/vals persisted from page to page -
YUI 2 is trying to use the storage utility and followed the example that worked (on the same page) ); But when I make another page (say page 2.html) and try to use the key, then I come back for the price.
So I call on Page 1:
LocalStorageEngine.setItem ('TestText', 'This is a Victory (Local Storage Engine)');
And if I use getItem on the same page, I see it, but if I say page 2.html:
Warning (localStorageEngine.getItem ('testText'));
I was nullified back I thought that this was the point I included in addition to jQuery 1.4.2 in the following
src = "http: //yui.yahooapis.com/combo?2.8.1/build/yahoo-dom-environment/johoo-dome-video.js & 2.8.1 / build / cookie / cookie- min.js & 2.8 1 / build / element / element-min.js & 2.8.1 / build / swf / swf min. Js & amp; 2.8.1 / build / swiftstore / swiftstore-min.js & amp; 2.8.1 / build / Storage / storage-min.js "
Here my javascript code is big Part:
//YAHOO.util.Event.onDOMReady (function () {jQuery (document) .ready (function () {var localStorageEngine; try {localStorageEngine = YAHOO.util.StorageManager.get ( YAHOO.util. StorageEngineHTML5.ENGINE_NAME, YAHOO.util.StorageManager.LOCATION_LOCAL, {force: false, in order: [YAHOO.util.StorageEngineHTML5, YAHOO.util.StorageEngineSWF, YAHOO.util.StorageEngineGears]});} catch (e) {YAHOO.log ("There is no supported storage mechanism present."); LocalStorageEngine = false; } If (localStorageEngine) {localStorageEngine.subscribe (localStorageEngine.CE_READY, function () {localStorageEngine.setItem ( 'testText',) 'This win (local storage engine)'; localStorageEngine.setItem ( 'testNumber', 1234567890); localStorageEngine .setItem ( 'testBoolean', true); alert (localStorageEngine.getItem ( 'testText')); console.log ( "lane:", localStorageEngine.length); console.log ( "key:", localStorageEngine.hasKey ( "Testtext"));}); }}); Eric's answer (very useful!) Worked, but in my case it clearly came out for the SDF line (do not use jquery documents instead of the same as Yahoo) Here's the proper code that is quite another otherwise://yahukutilkiventkondomreadyr (function () {Jkweri (document) Kredi (function () {Yahukutilkstorogingineswfa. Swfurl = "assets / Swfstore2-8-lkswf;Edit 2 Apology for dirty editing, but I am back to this post because I need to apply now And on the example of Eric, the second page (though he may choose to take it down) is still setting the price before receiving it, so it does not really give an example of maintaining the value between the pages. are added to the page and it went back to a warning when I GetItem being zero:
/ * localStorageEngine.setItem ( 'testText', 'win the (local storage engine) Is'); localStorageEngine.setItem ('tastemember', 1234567890); LocalestGenetics.Set Item ('TestBooney' is true); * /Essentially commenting on code set on page 2. After reading more about the underlying DOM S, the torque object I see is connected to a particular domain. For example, if I do:
sessionStorage.setItem ("name", "rob");I do not have an operation on my local machine, but if I upload it to a server it works. This was also with examples of storage utility and it also worked. So the essence is placed on the server.
rob,
i originally copy and paste it from your own code Set up two test pages:
Whenever I go from one to the other, I get success popups every time.
The only important difference between my code and yours is the jQuery note (Note: this does not eventually have any effect on functionality) and in addition to the SWF location (which is important as a fallback for browsers. 5 storage support; Update: The solution to this problem was Rob) but I tested it in Safari 5 and FF 3.6, so it should have used the HTML5 support directly.
Do these pages work for you?
- Eric
Comments
Post a Comment