How to Get Query Strings in Javascript From AS3

The ActionScript language lets you redirect to other HTML pages, such as AS3, in your website. Use JavaScript to parse the query string values passed from the ActionScript pages. The query string is the part of the website URL that contains key-value pairs. The question mark character denotes the query string values, and the JS "split" function parses the values from the URL.

Instructions

    • 1

      Right-click the HTML file you want to use to parse the query string from AS3. Click "Open With" and select your preferred JavaScript editor.

    • 2

      Retrieve the list of query string values and split the string into the key-value pairs. The key value pairs must be split again to see the data from the variable, but the following code gets a list of the pairs:

      var querystring = window.location.search.substring(1);
      var values = querystring.split("&");

    • 3

      Split the values from its associate key variable. The following code loops through each of the pairs and places the results into an array variable named "parsed":

      for (values i=0;i<values.length;i++) {
      var parsed= values[i].split("=");
      }

    • 4

      Display the parsed variables. For instance, the following code displays the first value:

      document.write(parsed[1]);

Related Searches:

References

Comments

Related Ads

Featured