Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * getHash of location url
- *
- * @param {boolean} exclude_get - hash = substing from # to ?
- * @param {string} regex
- * @method getHash
- * @return
- * @usage Tc.Utils.Globals.getHash(true,/^[a-z0-9_\.-]*$/i)
- */
- getHash: function(exclude_get,regex) {
- var hash = window.location.hash
- ,no_get = (typeof no_get !== 'boolean')? true : no_get
- ,stop = no_get ? hash.indexOf('?') : -1
- ,hashval // init
- ;
- // if there was no question mark in the hash, or no_get parameter is set to false
- hashval = (stop == -1)
- ? hash.substring(1) // remove #
- : hash.substring(1,stop) // remove # and exlude everything after '?'
- ;
- // security check: check if hash match regex
- if (regex) hashval = regex.test(hashval) ? hashval: '';
- return hashval;
- },
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement