Sometimes in javascript you have the variable that you need to use in the url, as a parameter passed in GET to the page, but you don’t have it in page. You can retrieve those data analyzing the window.location.href string. Here is the Javascript function that does the work, pass to it the variable name of the variable you need:
function gup( varname ) { varname = varname.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); var regexS = "[\\?&]"+varname+"=([^&#]*)"; var regex = new RegExp( regexS ); var results = regex.exec( window.location.href ); if( results == null ) return ""; else return results[1]; }
Another usefull function is the one that get the file name of the current page from the url.
I generally use this api : https://sourceforge.net/p/js-urlparam-omt/wiki/Home/