var text = /(?:\?|&)text=(\S*?)(?:&|$)/.exec(window.location.search) text = text?text[1]:false alert(text)