Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Mar 2008
    Posts
    61
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Exclamation Get URL Parameters Using Javascript

    So what I need to do is pretty much say

    "If &type=1 is at the end of document.URL than do this function .. if &type=1 ISNT in the URL ... than do something else" (kinda like if/else)
    Last edited by WebmasterLULZ; 05-04-2008 at 04:54 AM.

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,730
    Thanks
    202
    Thanked 2,508 Times in 2,486 Posts
    Code:
    var theURL = window.location;  // or var theUrl = document.URL;
    if (/(&type=1)$/i.test(theURL)) {  // returns true if ends in &type=1
    dothis();
    }
    else {
    dothat();
    }
    "I cannot conceive that anybody will require multiplications at the rate of 40,000 or even 4,000 per hour ..." -- F. H. Wales (1936)
    Last edited by Philip M; 05-04-2008 at 11:07 AM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •