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?
It's origin-specific. That means protocol + hostname [+ non-standard port] (e.g. "http://stackoverflow.com" != "https://stackoverflow.com")
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.
精彩评论