NOTICE

Adfly Links not working Find Direct Links HERE

How to GET URL parameter in javascript with Int and String Parameters easily










In JavaScript oand jQuery there is no straight or easy to use inbuilt function like JSP or PHP to fetch or get URL parameters so it takes a lot of time to create such functions which can be so long or heavy to execute. I worked on one of my problem regarding same and came up with these tow functions. First function is for getting url parameters in int form or numerical and other function is to Get URL parameter in Strings.

/* THIS FUNCTION IS TO FETCH INT PARAMETER VALUES */
function getParametera(param) {
                var val = document.URL;
                var url = val.substr(val.indexOf(param))  
                var n=parseInt(url.replace(param+"=",""));
                alert(n); 
}
getParametera("page");
getParametera("pagee");

/*THIS FUNCTION IS TO FETCH STRING PARAMETER*/
function getParameter(param) {
                var val = document.URL;
                var url = val.substr(val.indexOf(param))  
                var n=url.replace(param+"=","");
                alert(n); 
}
getParameter("str");

0 comments :

Feel free to leave comment if you like above widget, have any questions or just say Hi! :)