package com.lj.utils
{
import flash.external.ExternalInterface;
import mx.core.Application;
import mx.utils.URLUtil;
/**
* <p>Title:URL工具类 </p>
* <p>Description:URL</p>
* <p>Copyright: 个人所有</p>
* <p>Company: 刘军</p>
* @author 刘军 TomLiu
* @version 1.0 LastUpdata: 2012-12-29
*/
public class URLUtil
{
protected static const WINDOW_OPEN_FUNCTION:String="window.open";
/**
* 打开新页面
* @param url
* @param window
* @param features
*/
public static function openHtmlWindow(url:String, window:String="_blank", features:String=""):void
{
ExternalInterface.call(WINDOW_OPEN_FUNCTION, url, window, features);
}
/**
* 获取URL的参数
* @return
*/
public static function getHtmlURLParams():Object
{
var params:Object={};
//location.search是从当前URL的?号开始的字符串
var query:String=ExternalInterface.call("window.location.search.substring", 1);
if (query)
{
var pairs:Array=query.split("&");
for (var i:uint=0; i < pairs.length; i++)
{
var pos:int=pairs[i].indexOf("=");
if (pos != -1)
{
var argname:String=pairs[i].substring(0, pos);
var value:String=pairs[i].substring(pos + 1);
params[argname]=value;
}
}
}
return params;
}
/**
* 系统部署到服务器上时,获取服务器的域名URL包括端口号
*/
public static function getRootURL():String
{
return ExternalInterface.call("window.location.hostname");
}
/**
* 系统部署到服务器上时,获取站点的URL
* @return
*/
public static function getContentURL():String{
return ExternalInterface.call("window.location");
}
}
}
URL工具类 AS3
最新推荐文章于 2022-11-14 23:22:08 发布