[AS3]as3.0中navigateToURL用法示例
[AS3]as3.0中navigateToURL用法示例,navigateToURL() 可以用来打开一个新的浏览器窗口,也可以用来flex和js之间的通信,比如打开一个新窗口
navigateToURL() 可以用来打开一个新的浏览器窗口,也可以用来flex和js之间的通信,比如打开一个新窗口:
- var url:URLRequest = new URLRequest("http://www.cuplayer.com");
- navigateToURL(url, "_blank");
这个函数也可以用来执行js,例如:
- var url:URLRequest = new URLRequest(“javascript:window.close()”);
或者:
- var urlLURLRequest = new URLRequest(“javascript:myFun(para1…paran)”)
myFun()函数是html页面的script部分定义的,函数参数一定要有引号!
- navigateToURL(url, "_self");
也可以用来发送email:
- var urlURLRequest = new URLRequest("mailto:servetime@cuplayer.com");
- navigateToURL(url, "_blank");
阻止navigateToURL弹窗
- package FlashCode.utils{
- import flash.display.Sprite;
- import flash.net.URLRequest;
- import flash.net.navigateToURL;
- import flash.external.ExternalInterface;
- public class openWindow {
- public function openWindow(url:String, window:String="_blank", features:String=""){
- var WINDOW_OPEN_FUNCTION:String = "window.open";
- var myURL:URLRequest = new URLRequest(url);
- var browserName:String = getBrowserName();
- if(getBrowserName() == "Firefox"){
- ExternalInterface.call(WINDOW_OPEN_FUNCTION, url, window, features);
- }
- //If IE,
- else if(browserName == "IE"){
- ExternalInterface.call(WINDOW_OPEN_FUNCTION, url, window, features);
- //ExternalInterface.call("function setWMWindow() {window.open('" + url + "');}");
- }
- //If Safari
- else if(browserName == "Safari"){
- navigateToURL(myURL, window);
- }
- //If Opera
- else if(browserName == "Opera"){
- navigateToURL(myURL, window);
- } else {
- navigateToURL(myURL, window);
- }
- /*Alternate methodology...
- var popSuccess:Boolean = ExternalInterface.call(WINDOW_OPEN_FUNCTION, url, window, features);
- if(popSuccess == false){
- navigateToURL(myURL, window);
- }*/
- }
- private function getBrowserName():String{
- var browser:String;
- //Uses external interface to reach out to browser and grab browser useragent info.
- var browserAgent:String = ExternalInterface.call("function getBrowser(){return navigator.userAgent;}");
- // Debug.text += "Browser Info: [" + browserAgent + "]";
- //Determines brand of browser using a find index. If not found indexOf returns (-1).
- if(browserAgent != null && browserAgent.indexOf("Firefox") >= 0) {
- browser = "Firefox";
- }
- else if(browserAgent != null && browserAgent.indexOf("Safari") >= 0){
- browser = "Safari";
- }
- else if(browserAgent != null && browserAgent.indexOf("MSIE") >= 0){
- browser = "IE";
- }
- else if(browserAgent != null && browserAgent.indexOf("Opera") >= 0){
- browser = "Opera";
- }
- else {
- browser = "Undefined";
- }
- return browser;
- }
- }
- }
热门文章推荐
- [HLS]做自己的m3u8点播系统使用HTTP Live Streaming(HLS技术)
- [FMS]FMS流媒体服务器配置与使用相关的介绍
- [AS3]什么是M3U8,与HTML5的区别是什么
- AS2.0 让flash自适应全屏,并且不自动缩放
- [AS3]as3.0的sound类常用技巧整理
- [AS3]as3与ByteArray详解、ByteArray介绍、ByteArray用法
- 关于RTMP,RTMPT,RTMPS,RTMPE,RTMPTE协议的介绍
- [JS]分享浏览器弹出窗口不被拦截JS示例
请稍候...