문제

I've have the back and foward buttons working via History.js in both HTML5 and HTML4 browsers.

I'm now attempting to add bookmark support by parsing the url, and loading the content in the querystring. The code I normally use to do this is:

var urlParams = {};
            (function () {
            var match,
                pl     = /\+/g,  
                search = /([^&=]+)=?([^&]*)/g,
                decode = function (s) { return decodeURIComponent(s.replace(pl, " ")); },
                query  = window.location.search.substring(1);

            while (match = search.exec(query))
            urlParams[decode(match[1])] = decode(match[2]);
            })();  

This works great for the HTML5, but obviously does not work for the HTML4. Whats a good way to parse the hash in HTML4, and the substring in HTML5?

도움이 되었습니까?

해결책

found a solution on this page: https://getsatisfaction.com/balupton/topics/history_js_and_retrieving_state_from_a_url

"You can use this function however from one of my utility projects called jQuery Sparkle to do what you need: https://github.com/balupton/jquery-sparkle/blob/master/scripts/resources/core.string.js#L164

So you would do this:

var State = History.getState(), dataQuery = State.url. queryStringToJSON();"
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top