Home » ActionScript 2.0, ActionScript 3.0, Flash CS4, Flex, HTML5

Open Html popup Window in as3 using JavaScript

20 December 2010 No Comment
Share on Facebook

This article discuss how to open a HTML popup window in Flash or Flex using ActionScript and JavaScript.
The Idea is to call the “open” method of the Window Object in JavaScript. Unlike in Standard Javascript function which will be embedded in HTML. Here we will embed the JavaScript function inside the Flash actionscript which communicates to browser to direct and open a new Window.

ActionScript code to Open Popup window in as3

Window_mc.addEventListener(MouseEvent.MOUSE_DOWN, OpenWindowFunction);
function OpenWindowFunction(e:MouseEvent):void {
  var jscommand:String = "window.open('http://www.designscripting.com','win','height=200,
  var url:URLRequest = new URLRequest("javascript:" + jscommand + " void(0);");
  navigateToURL(url, "_blank");

Lets have a look at JavaScript Window.Open Method

Window.Open Syntax:

window.open('url to open','window name','attribute1,attribute2..');

1.’url to open’
The web address need to be opened in new window

2. ‘window name’
This is the name we will reference in the code later

3. ‘attribute1,attribute2′
There are many attributes, we can have choice to select any of them

Attributes for Window Open Method

1. width=300
Use this to define the width of the new window.

2. height=200
Use this to define the height of the new window.

3. resizable=yes or no
Use this to control whether or not you want the user to be able to resize the window.

4. scrollbars=yes or no
This lets you decide whether or not to have scrollbars on the window.

5. toolbar=yes or no
Whether or not the new window should have the browser navigation bar at the top (The back, foward, stop buttons..etc.).

6. location=yes or no
Whether or not you wish to show the location box with the current url (The place to type http://address).

7. directories=yes or no
Whether or not the window should show the extra buttons. (what’s cool, personal buttons, etc…).

8. status=yes or no
Whether or not to show the window status bar at the bottom of the window.

9. menubar=yes or no
Whether or not to show the menus at the top of the window (File, Edit, etc…).


This method uses the getURL (ActionScript 2.0) or navigateToURL (ActionScript 3.0) command to create a new browser window by targeting a new, blank window.

ActionScript 2.0:

getURL("www.designscripting.com", "_blank");

ActionScript 3 .0:

 var url:URLRequest = new URLRequest("http://www.designscripting.com");
 navigateToURL(url, "_blank");


We don't share your email anywhere, grab our rss via feedburner

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.