URL工具类 AS3


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");
}


}
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值