www.webdeveloper.com
Results 1 to 3 of 3

Thread: [RESOLVED] Parse Data from URL and Redirect

  1. #1
    Join Date
    Aug 2010
    Posts
    2

    resolved [RESOLVED] Parse Data from URL and Redirect

    Admittedly, I am quite a newbie when it comes to writing in JavaScript. I am not even sure this is possible to do using JavaScript, but if anyone can offer some input it would be greatly appreciated.

    I have users being sent to a portal page. In the URL I have a few parameters passing that identify what network they are coming from. Here is an example of the URL string that passes when the user navigates to the portal page.

    -----------------
    http://www.redirectpage.com/web/port...me&METHOD=None
    ------------------

    What I would like to do is, when I get a user on a specific port (above PORT=502), redirect the user to a different portal page URL.

    That being said, I would need to parse out the port number.. and have the original portal page automatically redirect the user to a different portal page based on that data alone.

    Is this possible to do using just javascript and html?

    Any help again is greatly appreciated!

    Thank you!

  2. #2
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Code:
    var data=location.search;
    if(data) {
        data=location.search.substring(1); // remove the '?'
        data=data.split('&');
        var pairs={};
        for(var i=0; i<data.length; i++){
            var tmp=data[i].split('=');
            pairs[tmp[0]]=tmp[1];
            }
        for (var i in pairs) { // display name value
            document.write(i+"="+pairs[i]+"<br>");
            }
        }
    pairs['PORT'] would give the port number
    At least 98% of internet users' DNA is identical to that of chimpanzees

  3. #3
    Join Date
    Aug 2010
    Posts
    2
    This worked perfectly. Thank you so much for the help!! Saved me a huge headache.. and I no longer have to configure a seperate external web server / RADIUS server. Much appreciated.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles