• 0

web storage works offline, but not online


Question

hello

i have a site where i use web storage ( http://en.wikipedia.org/wiki/Web_storage ) and it works offline but when i put it online, it doesnt work. vry very strange. a server cannot limit if i use web storage or not rite??? its works offline on all browsers when it is on my local server but when on online, it doesnt work.

wat could be rong????

Recommended Posts

  • 0

I use both local and session storage objects in my applications; are the domains different from offline and online? If you set a key value pair when browsing localhost, then you will not be able to access them when you are browsing www.yoursite.com (and vice-versa).

subdomains are also subject to this; web.yoursite.come can not access mail.yoursite.com objects.

  • 0

I use both local and session storage objects in my applications; are the domains different from offline and online? If you set a key value pair when browsing localhost, then you will not be able to access them when you are browsing www.yoursite.com (and vice-versa).

subdomains are also subject to this; web.yoursite.come can not access mail.yoursite.com objects.

no.

on local i use: example.ex/something and example.ex/somethingelse that works (on both)

online i use (for the same above): something.example.com and somethingelse.example.com that does not work (on either)

my feeling is that indeed that ****ing subdomain has sumthin to do with it. any workaround????

  • 0

You could move your localStorage code to the root domain (so example.com), then embed the code through an iframe on both subdomains, and send messages between the two documents as a way to do it.

do u have anywhere i can see examples or tutorials or more indepth information?

thank u

  • 0

http://www.nczonline...n-localstorage/

Edit: You'll want to ensure that no other sites can embed the code and issue commands to your code, it covers it in the article but it won't hurt to mention it again.

:laugh: this is the same exact page i looked up when i posted about maybe subdomains being a pain.....

i have several problems with that implementation......*sighs* im not sure this is going to be easy as the situation is kind of complicated.

my root domain is tecnically a subdomain....so thats going to be problematic.

if you have sum time to spare (and want to), The_Decryptor, a 1 on 1 pm session wud be nice and helpful.

tanks to all for the advice and comments

  • 0

Well, if you're in the situation where you don't control the root domain, only the subdomains, then you'd have to have one "master" subdomain, and have the second subdomain use that for storage (Using the same postMessage setup as you would use for subdomain > domain communication)

  • 0

Well, if you're in the situation where you don't control the root domain, only the subdomains, then you'd have to have one "master" subdomain, and have the second subdomain use that for storage (Using the same postMessage setup as you would use for subdomain > domain communication)

so it wud be the same implementation? ok will give it a go and see if sumthin explodes.

btw this also works on my local rite? ill implement in first in my local then pass it...

  • 0

got it to work (had some stuff to do)

i just have a very noob javascript question:


/*java script up here*/
var remoteStorage = new CrossDomainStorage("http://example.dev", "/server.html");
remoteStorage.requestValue("lookforme", function(key, value){
alert("The value for '" + key + "' is '" + value + "'");

});
alert ("alert 2 : I want to print/use value on the outside" + value);
/*javascript down here*/
[/CODE]

pretty selfexplains....i want to use value on the onside of that little variable/function (for example in that thing that says alert 2). how to do it????

  • 0

Should work, but not tested:

/*java script up here*/
var remoteStorage = new CrossDomainStorage("http://example.dev", "/server.html");
		 value = remoteStorage.requestValue("lookforme", function(key, value){
		 alert("The value for '" + key + "' is '" + value + "'");
		 return value;

		 });
alert ("alert 2 : I want to print/use value on the outside" + value);
/*javascript down here*/

  • 0

/*java script up here*/
var remoteStorageValue = "";
var remoteStorage = new CrossDomainStorage("http://example.dev", "/server.html");
                 remoteStorage.requestValue("lookforme", function(key, value){
                 alert("The value for '" + key + "' is '" + value + "'");
                 remoteStorageValue = value;
                 });
alert ("alert 2 : I want to print/use value on the outside" + remoteStorageValue);
/*javascript down here*/

You have to set the global value within the callback function, returning it won't work (Since you're assigning the return of "requestValue" to the variable, not the value of the callback which can happen at a later time)

  • 0

/*java script up here*/
var remoteStorageValue = "";
var remoteStorage = new CrossDomainStorage("http://example.dev", "/server.html");
				 remoteStorage.requestValue("lookforme", function(key, value){
				 alert("The value for '" + key + "' is '" + value + "'");
				 remoteStorageValue = value;
				 });
alert ("alert 2 : I want to print/use value on the outside" + remoteStorageValue);
/*javascript down here*/

You have to set the global value within the callback function, returning it won't work (Since you're assigning the return of "requestValue" to the variable, not the value of the callback which can happen at a later time)

i changed it to that code and it says that RemoteStorageValue ' s value is simply undefined

  • 0

It shouldn't say that since the first line sets it to "", which is different from undefined.

There is another issue of course, the second alert will fire before the callback could/will, so it won't see the value that the callback will.

  • 0

It shouldn't say that since the first line sets it to "", which is different from undefined.

There is another issue of course, the second alert will fire before the callback could/will, so it won't see the value that the callback will.

well it is undefined.....tried putting a word and same thing.

and that other issue you mentioned, may have to do with it:

there are 2 lines:

alert("The value for '" + key + "' is '" + value + "'");

alert ("alert 2 : I want to print/use value on the outside" + remoteStorageValue);

well alert 2 pops up before "the value for...." so I imagine it is because of what you mentioned. how do i fix it???

  • 0

The only way to fix it is to structure your code such that you don't try reading the value directly after issuing the cross domain call. Even if it execute instantly, JavaScript won't call your callback function until after the current function has finished executing.

If you separate your code into 2 different sections, one which asks for information and one that processes it, you could just make the first part issue the cross-domain call, and have the callback function invoke the second part of your code.

  • 0

The only way to fix it is to structure your code such that you don't try reading the value directly after issuing the cross domain call. Even if it execute instantly, JavaScript won't call your callback function until after the current function has finished executing.

If you separate your code into 2 different sections, one which asks for information and one that processes it, you could just make the first part issue the cross-domain call, and have the callback function invoke the second part of your code.

Well the only thing that comes to mind is sumkind of "sleep" function after running that cross domain call. tis will give it enough time to finish and will be able to get the valuer rite?

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Microsoft's fast coding model MAI-Code-1-Flash comes to Copilot Business and Enterprise by Karthik Mudaliar Microsoft’s recently announced MAI-Code-1-Flash model is now generally available to GitHub Copilot Business and Copilot Enterprise customers. With this support, organizations can have more centralized policy controls and billing while finally being able to use Microsoft’s lightweight, first-party coding model. According to GitHub’s announcement, Business and Enterprise plan administrators must enable the MAI-Code-1-Flash policy in Copilot settings before developers can access the model. Microsoft says that MAI-Code-1-Flash is for fast, iterative coding work rather than the most demanding architectural or debugging tasks. GitHub’s official model comparison page says that the model is great for "general-purpose coding and writing," while it excels at fast, accurate code completions and explanations Microsoft introduced MAI-Code-1-Flash on June 2 as part of a broader collection of internally developed MAI models. GitHub subsequently expanded support to Copilot CLI, the Copilot cloud agent, GitHub.com chat, GitHub Mobile, Visual Studio, JetBrains IDEs, Eclipse, and Xcode, but said support for managed Business and Enterprise customers was still on the way. In Microsoft’s own benchmark testing, MAI-Code-1-Flash scored 51.2% on SWE-Bench Pro, compared with 35.2% for Anthropic’s Claude Haiku 4.5. Microsoft also claimed that the model used up to 60% fewer tokens on SWE-Bench Verified. Do note that these are vendor-run results rather than independent measurements. The model is billed at provider list pricing under GitHub’s usage-based system. GitHub currently lists MAI-Code-1-Flash at $0.75 per million input tokens, $0.075 per million cached input tokens, and $4.50 per million output tokens. For organizations, the main incentive to use MAI-Code-1-Flash is likely to be efficiency rather than maximum capability. A smaller model that responds quickly and limits unnecessary output is quite useful for repetitive agent tasks at scale, especially after GitHub Copilot’s move toward usage-based billing. The "Flash" model is recommended for fast work and not necessarily for huge repositories with loads of context. It's better if teams compare their output with other larger models, especially if they're working on security-sensitive changes and complex, multi-file work.
    • yes AND no the "original" or plain/normal Optiplex 7010 won't be getting any more new firmware updates BUT the Optiplex SFF/SFF Plus {small form factor}, Micro/Micro Plus & Tower/Tower Plus 7010 editions DO get new updates such as this new one   and here are similar guides from the Dell web site for Dell systems: https://www.dell.com/support/kbdoc/en-us/000390990/secure-boot-transition-faq https://www.dell.com/support/kbdoc/en-us/000347876/microsoft-2011-secure-boot-certificate-expiration
    • AT&T has been spying on US citizens with the NSA for decades.. they just know how to keep it more under wraps.. the evil level is still there.
  • Recent Achievements

    • One Year In
      bernmeister earned a badge
      One Year In
    • Week One Done
      Scoobystu earned a badge
      Week One Done
    • Week One Done
      tuben earned a badge
      Week One Done
    • First Post
      OffsetAbs earned a badge
      First Post
    • Reacting Well
      OffsetAbs earned a badge
      Reacting Well
  • Popular Contributors

    1. 1
      +primortal
      462
    2. 2
      +Edouard
      213
    3. 3
      PsYcHoKiLLa
      158
    4. 4
      Steven P.
      72
    5. 5
      FloatingFatMan
      71
  • Tell a friend

    Love Neowin? Tell a friend!