Get URL and Read URL Parameters in JavaScript, HaXe and AS3

Datetime:2016-08-23 02:54:36         Topic: JavaScript          Share        Original >>
Here to See The Original Article!!!

Find the URL of the embedding page of a swf is a very basic way for domain locking flash games. Similar things can be done for JavaScript based online games. To get the URL, in JavaScript you can use

var myURL=document.URL;

In HaXe (targeting JavaScript or HTML5), you can use

var myURL:String=js.Browser.window.document;

In AS3, to find the path url of the swf, you can use


and for finding the path url of the embedding page, you can use"window.location.href");

Besides, it's common to see url parameters, for example: " " To read the parameters, in the above example, that is "1234", "somestr" and "someotherstr", in JavaScript, you can use the snippet provided by or the function given at

In HaXe, you can use the following HaXe function

//translated from
function getQueryVariable(variable):String
       var query:String =;
       var vars:Array

  = query.split("&");
       for ( i in 0...vars.length) {
	   var pair:Array
   = vars[i].split("=");
	   if(pair[0] == variable){return pair[1];}


In AS3, if the parameters are given in the path of the swf' url, for example, " ", or if the parameters are declared in flashvars, then you can simply use " root.loaderInfo.parameters " object to access all the parameters, for example,

var myStr:String = root.loaderInfo.parameters.param1;

However, to read parameters of the embedding page' url, you still need the help of JavaScript, see the following pages for an example:


Put your ads here, just $200 per month.