Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. var getUrlParameter = function getUrlParameter(sParam) {
  2. var sPageURL = decodeURIComponent(window.location.search.substring(1)),
  3. sURLVariables = sPageURL.split('&'),
  4. sParameterName,
  5. i;
  6.  
  7. for (i = 0; i < sURLVariables.length; i++) {
  8. sParameterName = sURLVariables[i].split('=');
  9.  
  10. if (sParameterName[0] === sParam) {
  11. return sParameterName[1] === undefined ? true : sParameterName[1];
  12. }
  13. }
  14. };
  15. And this is how you can use this function assuming the URL is,
  16. http://dummy.com/?technology=jquery&blog=jquerybyexample.
  17.  
  18. var tech = getUrlParameter('technology');
  19. var blog = getUrlParameter('blog');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement