Results 1 to 4 of 4

Thread: VBscript to Javascript Translation

  1. #1

    Thread Starter
    Lively Member Nator's Avatar
    Join Date
    Nov 1999
    Location
    East Larryville, GA
    Posts
    80

    VBscript to Javascript Translation

    I still at the newbie stage as far as Javascript goes. How do you return a URL's Querystring using Javascript?

  2. #2
    BG
    Guest

    Question

    Hey Nator.

    I have the same question. Sorry I wish I could help. if you find Out could you e-mail me. I will do the same. [email protected]

    Thanks
    "B"

  3. #3
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    Not certain if there is a built in function for it, but you could just put the URL into a string object and parse it for:

    Code:
    <html> 
    <head> 
    <title>Select the products...</title> 
    <meta name="Microsoft Theme" content="none"> 
    <script language="JavaScript"> 
    function SearchDemo()
    {
       var r, re, ln;		//Declare variables.
       var qs = new String('');
       var s = new String(document.URL);
       re = "[?]";            	//Create regular expression pattern.
       r = s.search(re);            //Search the string.
       if (r != -1)
       {
           ln = s.length;
           qs = s.substring(r, ln);
       }
    
       return(qs);                   //Return the Boolean result.
    }
    function cmdDisplay_onclick()
    {
       window.alert(SearchDemo());
    }
    </script> 
    </head> 
    <body> 
    <input onclick="cmdDisplay_onclick()" type=button name=cmdDisplay value="ClickMe!">
    </body> 
    </html>
    If you copy this into a HTML document in your wwwroot folder for IIS and call it with a querystring, when you click on the button it will pop up a dialog with just the querystring. (You can't specify querystrings when calling a file locally.. at least I couldn't)

    That should get you close..
    oOOo--oOOo
    __/\/\onte96
    oOOo--oOOo
    Senior Programmer/Analyst
    MCP
    [email protected]
    [email protected]


    Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..

  4. #4
    Fanatic Member Psyrus's Avatar
    Join Date
    Jul 2000
    Location
    NJ
    Posts
    602
    Use:

    var myQuery;
    myQuery = location.search;

    This will return everthing from the "?" on. Then you can use the split() function to split the string on the "&"s, assuming that you have more than one value.


    Chris
    Chris

    VB 6.0 Calendar App Video Gamers Group
    Don't forget to rate people if they helped you.

Posting Permissions

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



Click Here to Expand Forum to Full Width