Return to Snippet

Revision: 13228
at April 15, 2009 11:27 by cbaigorri


Updated Code
package
{
	import flash.external.ExternalInterface;
	import flash.net.URLRequest;
	import flash.net.navigateToURL;
	
	public class HtmlPageUtils
	{
		
		public static function viewPopup(_address:String, _wname:String = "popup", _width:int = 400, _height:int = 400, _toolbar:String = "no", _scrollbar:String = "no", _resizeable:String = "yes"):void {
			var address:String = _address;
			var wname:String = _wname;
			var w:int = _width;
			var h:int = _height;
			var t:String = _toolbar;
			var s:String = _scrollbar;
			var r:String = _resizeable;
			
			if (ExternalInterface.available) {
				ExternalInterface.call("window.open", address, wname, "height=" + h + ",width=" + w + ",toolbar=" + t + ",scrollbars=" + s + ",resizable=" + r + "");
			}else {
				var jscommand:String = "window.open('" + address + "','" + wname + "','height=" + h + ",width=" + w + ",toolbar=" + t + ",scrollbars=" + s + ",resizable=" + r + "');";
				var url:URLRequest = new URLRequest("javascript:" + jscommand + " void(0);");
				try{
					navigateToURL(url,"_self");
				} catch (e:Error) {
					trace("Popup failed", e.message);
				}
			}
		}

	}
}

Revision: 13227
at April 15, 2009 11:25 by cbaigorri


Initial Code
package
{
	import flash.external.ExternalInterface;
	import flash.net.URLRequest;
	import flash.net.navigateToURL;
	
	public class HtmlPageUtils
	{
		public function HtmlPageUtils()
		{
		}
		
		public static function viewPopup(_address:String, _wname:String = "popup", _width:int = 400, _height:int = 400, _toolbar:String = "no", _scrollbar:String = "no", _resizeable:String = "yes"):void {
			var address:String = _address;
			var wname:String = _wname;
			var w:int = _width;
			var h:int = _height;
			var t:String = _toolbar;
			var s:String = _scrollbar;
			var r:String = _resizeable;
			
			if (ExternalInterface.available) {
				ExternalInterface.call("window.open", address, wname, "height=" + h + ",width=" + w + ",toolbar=" + t + ",scrollbars=" + s + ",resizable=" + r + "");
			}else {
				var jscommand:String = "window.open('" + address + "','" + wname + "','height=" + h + ",width=" + w + ",toolbar=" + t + ",scrollbars=" + s + ",resizable=" + r + "');";
				var url:URLRequest = new URLRequest("javascript:" + jscommand + " void(0);");
				try{
					navigateToURL(url,"_self");
				} catch (e:Error) {
					trace("Popup failed", e.message);
				}
			}
		}

	}
}

Initial URL
http://www.chrisbaigorri.com

Initial Description
HtmlPageUtils.viewPopup("http://www.google.ca", "mypopup");

Initial Title
AS3 Javascript Popup

Initial Tags

                                

Initial Language
ActionScript 3