开发者

html5 localstorage sql, request for searching

开发者 https://www.devze.com 2023-03-29 22:23 出处:网络
i am wondering if the \"LIKE \'%pattern%\' is available in the sql like html5 request storage engine?

i am wondering if the "LIKE '%pattern%' is available in the sql like html5 request storage engine?

i would like to implement a local search to know which embedded html pages to display in a full offline mobile web app开发者_JS百科lication...

exemple : A.html -> "info about A" B.html -> "info about B"

a search input combobox, the user type "A", then a sql request is done with like "%A%" Then all matched results are displayed, then the user select the page he really wants, then the page is displayed...

Have you any ideas?

Thank you


I'm guessing you just need something like this.

http://www.tizag.com/javascriptT/javascript-string-search.php


It looks like the localStorage is not searchable with conditions like a SQL database is, and this is something that is probably going to be addressed by IndexedDB when it is finally implemented.

The best seems to be to loop over all localStorage items and then try to match each key or value using a regex. Like so:

for (var i = 0, i < window.localStorage.length, i++) {
    index = window.localStorage.key(i);
    if (index.match(/^string/)) {
        // your code...
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号