3 messages in com.googlegroups.google-gearsRe: localServer has no properties...| From | Sent On | Attachments |
|---|---|---|
| fisch3r | 17 Oct 2007 13:23 | |
| Ben Lisbakken | 17 Oct 2007 14:40 | |
| fisch3r | 18 Oct 2007 04:36 |
| Subject: | Re: localServer has no properties...![]() |
|---|---|
| From: | fisch3r (fisc...@gmail.com) |
| Date: | 10/18/2007 04:36:05 AM |
| List: | com.googlegroups.google-gears |
Thanks for your help!
On Oct 17, 11:40 pm, "Ben Lisbakken" <lisb...@google.com> wrote:
Fisch3r --
You're problem is a Javascript problem. Because you use forms with the onsubmit handler, when you click "save!" or "remove!" it is like re-loading the page. Everything in your original window object is lost.
When you click "save!", it initializes the localServer and store. But when you click "remove!" you have a whole new instance of localServer and store. Since you don't initialize localServer and store in the remove() function, it throws the error about not being able to find the localServer.
The simplest fix is to change your code from this: <form id="save" onsubmit="save()"> <input type="submit" name="saveb" value="save!" /> </form> <form id="remove" onsubmit="remove()"> <input type="submit" name="removeb" value="remove!" /> </form>
To this: <input type="submit" name="saveb" value="save!" onclick="save();" /> <input type="submit" name="removeb" value="remove!" onclick="remove();" />
Also, as a side note, your lines that have this: location.href = "http://gears.google.com/? action=install&message=Please install GoogleGears!" + "&return=http://localhost/gears/";
have an extra new line in them, between ? and action=. This might be caused by e-mail though :)
Hope that helps, Ben
On 10/17/07, fisch3r <fisc...@gmail.com> wrote:
Hi, I just wanted to build a gears 'hello world'. I use two buttons: save and remove. Saving the page works so far but removing fails....error message is "localServer has no properties", line: "if (localServer.openManagedStore('notepad')) {" code:
the index.html looks like this:
<html> <head> <script src="gears_init.js"></script> <script src="application.js"></script> <script> if (!window.google || !google.gears) { location.href = "http://gears.google.com/? action=install&message=Please install GoogleGears!" + "&return=http://localhost/gears/"; } </script> <title>Gears HelloWorld</title> </head> <body> <p> <form id="save" onsubmit="save()"> <input type="submit" name="saveb" value="save!" /> </form> <form id="remove" onsubmit="remove()">
<input type="submit" name="removeb" value="remove!" /> </form> </p> <h1>Hello World!</h1> </body> </html>
the code of the application.js:
var localServer; var store;
function save() { if (!window.google || !google.gears) { location.href = "http://gears.google.com/? action=install&message=Please install GoogleGears!" + "&return=http://fima.uttx.net"; } localServer = google.gears.factory.create('beta.localserver', '1.0'); store = localServer.createManagedStore('notepad');
store.manifestUrl = 'manifest.json'; store.checkForUpdate();
if (store.currentVersion) { alert('done! The version stored is: ' + store.currentVersion); } else if (store.updateStatus == 3) { alert("Error: " + store.lastErrorMessage); } }
function remove() { if (!window.google || !google.gears) { location.href = "http://gears.google.com/? action=install&message=Please install GoogleGears!" + "&return=http://fima.uttx.net"; } if (localServer.openManagedStore('notepad')) { localServer.removeManagedStore('notepad'); store = null; alert('done! Local store removed.'); } else { alert('Fehler...'); }
}
any ideas?




