jQuery handling of URL params?

0 views
Skip to first unread message

Audrey A Lee

unread,
Aug 22, 2009, 6:13:22 PM8/22/09
to forumgrouper
Hello,

Rails has a hash named "params" which contains information from my
current URL.

Does jQuery have something like params?

Related question:

What is the jQuery-way of getting data out of the current URL?

-Audrey

Audrey A Lee

unread,
Aug 22, 2009, 7:42:56 PM8/22/09
to forumgrouper
not the jQuery way but terse and effective:
http://www.netlobo.com/url_query_string_javascript.html



function gup( name )
{
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec( window.location.href );
if( results == null )
return "";
else
return results[1];
}

// http://www.foo.com/index.html?bob=123&frank=321&tom=213#top
// var frank_param = gup( 'frank' );
Reply all
Reply to author
Forward
0 new messages