Henry
Henry

Reputation: 1065

HTML5 Web SQL db domain specific?

Please correct me if I'm wrong, but I believe the Web DB is domain specific and you should be able to access it from any page from within the same domain? For some reason I'm not able to.. so xxxxxx.com/index.html creates a DB and xxxxxx.com/index2.html doesn't see it.. I verified in Chrome 10+ and Safari 5.. any ideas?

Upvotes: 2

Views: 1073

Answers (2)

Henry
Henry

Reputation: 1065

Ok, great news for me - I was able to figure this out on my own.

So Web SQL uses Same Domain Origin Policy as Eli was saying, however the answer to my question was how to access the db from a separate page on the same domain since it wasn't showing up.

You must open the DB on every page you want to access. This is different from local storage, i know.

So on index.html i created a db instance with:

db = openDatabase('mydb', '1.0', 'feeds', 2 * 1024 * 1024);

and I needed to do the same for index2.html, I threw it into an onload function and boom! it works.

super happy.

Upvotes: 1

Eli Grey
Eli Grey

Reputation: 35895

It's origin-specific. That means protocol + hostname [+ non-standard port] (e.g. "http://stackoverflow.com" != "https://stackoverflow.com")

Upvotes: 1

Related Questions