url parameter to save is in JavaScript
I would like to insert a parameter value found the url into my javascript code.. So basically i have the following url www.rene-zamm.com/mp-dthanks.asp?gglid=1231开发者_Python百科23123
Now i have the following javascript code in the same page and i want that number in the url to be visible also in the javascript code below:
var gwoTracker=_gat._getTracker("UA-1639156-3");
gwoTracker._trackPageview("/**NUMBER OF URL HERE**/goal");
Can someone help me please?
You need to parse the querystring. Javascript has no inbuilt way of doing this easily, but there are some nice functions you can use:
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.netlobo.com/url_query_string_javascript.html
Then in your example you could do:
var queryData = gup("gglid");
var gwoTracker=_gat._getTracker("UA-1639156-3"); gwoTracker._trackPageview("/" + queryData + "/goal");
精彩评论