i can't figure out how correctly use push state. i'm getting weird url's so:
http://website.net/home?http://website.net/home=undefined&tab=browse
and can't seem work no matter try. need domain/path stay same, want rebuild querystring (which in function) apply history.pushstate()
here's basic @ code, abbreviated show problem in question.
var sk = { //push function pushstate: function(qs,callback){ var = 0, uri = ''; $.each(qs,function(k,v){ if(k=="" || v==""){ delete qs[k]; } }); $.each(qs,function(k,v){ if(i == 0){ uri +='?'; }else{ uri +='&'; } uri +=k+'='+encodeuricomponent(v); i++; }); var obj ={ title: $('title').html(), url: uri } if(typeof callback !== "undefined" && callback !== false){ obj[callback[0]] = callback[1]; } history.pushstate(obj,obj.title,obj.url); }, //parse current url , return querystring getqsvars : function(){ var vars = {}, hash; var hashes = window.location.href.slice(window.location.href.indexof('?') + 1).split('&'); for(var = 0; < hashes.length; i++) { hash = hashes[i].split('='); vars[hash[0]] = hash[1]; } return vars; }, };
Comments
Post a Comment