javascript - doing substring in window.location.hash -
Window in any way. Location.hash is being handled differently in different browsers. If I have a URL, then it is as follows
http://maps-demo.bytecraft.com.my/postdemo/parcel # parcel / history / 1? As = Jason & amp; Desc [] = ctime & amp; [Desc = P> window.location.hash.substring (14, window.location.hash.search (/ \? / G));
I have no problem in Firefox 3.0.10 but the same substrings statement does not work in opera 9.60.
After some quick search, I find some interesting information that can help
- window.location.hash should always return the urlencoded string, but this is a
If the hash is part of the URL, there are encoded characters (see Core_JavaScript_1.5_Reference: Global_Functions: encodeurIComponent), hash divorced url part. This is a bug in Firefox Href, Search and PathName, right, Encoded URL parts come back.
- Opera only returns # parcel / history / 1 and ignores the remaining string, and this is my main reason why the substrings statement failed ...
Am I better that I want to remove the string between # parcel / history / and? = As JSON? Besides the regular expression ?!
Try it out:
var match = window.location.href . Match (/^[^#]+#([^?]*)\??(.*)/); Var Hashpath = Match [1]; Var hash = Match [2]; It matches the following parts of the hash:
... # parcel / history / 1 = as = json & desc [] = ctime & Desc [] = History_id \ ______________ / \ ____________________________________ / hashpath hashquaxi
Comments
Post a Comment