I have an url like http://example.com/#var1=1 I'm adding new query params to the hash using this function:
function appendHash(name, val){ var currentHash = location.hash; if(!currentHash){ location.hash = '#'+name+'='+val; }else{ location.hash = currentHash+'&'+name+'='+val; } }; However, this won't work as it should if the new name=val already exists in the current hash, e.g if current hash is #var1=1&var2=2 and I add var2=2 it will be appended again, and I don't want this to happen. What I need is to check if the new name and val already exist in the url and if exists skip it. Or maybe some other function will help?