get window.location.hash
♥0 |
Line 46 |
Modified 2010-09-06 12:16:56 |
MIT License
archived:2017-03-20 16:01:29
ActionScript3 source code
/**
* Copyright andyshang ( http://wonderfl.net/user/andyshang )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/htuR
*/
package
{
import flash.system.Security;
import flash.display.Loader;
import flash.display.Sprite;
import flash.events.KeyboardEvent;
import flash.external.ExternalInterface;
import flash.net.URLRequest;
import flash.text.TextField;
public class JSDemo extends Sprite
{
public function JSDemo()
{
Security.allowDomain("*");
var textField:TextField = new TextField();
textField.autoSize = "left";
addChild(textField);
textField.text = "the hash is : " + getHash();
}
public function getHash():String
{
var res:String;
if(ExternalInterface.available)
{
try
{
res = ExternalInterface.call("\
function()\
{\
return window.location.hash;\
}\
");
}
catch(e:Error)
{
res = "security error";
}
}
else
{
res = "not available";
}
return res;
}
}
}