Arjan Eising

Pages

Feeds

You can subscribe to my feeds to get notified when I have written a new post, using RSS or Atom.

Categories

Archives

JavaScript Get function

Blog friend Ben shared a nice JavaScript Get function. As the name says, it returns the wanted Get variable.

// Author: Benjamin Carlier, http://benjamincarlier.be/
var uri={
get:function(id){
return unescape(location.search.match('(?:\\?|\&)' + id + '=([^\&]*)')[1].replace(/\+/g, " "))}
}

To use it, only var term = uri.get('q'); is needed to put the search terms in the variable term.

13 responses to JavaScript Get function

Respond

Post a comment

Like you, I hate spam. So your e-mail address will not be shown on this website, nor sold to the rich and notorious. For your comment you can use the daily XHTML elements: a (do use the title attribute, please), abbr, acronym, blockquote, code, em and strong. Remember, your comment needs to be written in English, and also be an useful addition to the article or other comments. If not, I might want to delete your comment.