MACROMEDIA FLASH  back to
LAUNCHING A NEW WINDOW: TECHNIQUE TWO  


<FONT COLOR="#FFFFFF">If you are reading this message you do not have Macromedia Flash installed properly in your browser. You need a browser that supports either Netscape plugins, or ActiveX. Please visit the <A HREF="installflash.html">Flash installation instructions</A>for more information.</FONT>

Technique Two: Get URL JavaScript Call

Unsupported by: IE 3.0 (PC only), IE 2.0, IE 4.5 (Mac only)

Right-click (or CTRL-Click on Mac) and choose "Save Link As..." to
[Download the sample .zip file]

description:
In Technique two, we avoid FSCommand altogether--and hence the requirement for ActiveX or LiveConnect--by using a call to JavaScript in a getURL action on a frame or button. The JavaScript is simply a function that pops up a window. This technique is known as the "javascript:" protocol, and works exactly like normal calls to javascript in the HREF of an anchor tag (eg. <A HREF="javascript:myfunction()">).

how to:

  1. Add a getURL action to a frame or a button.
  2. In the URL field (was "Network URL" in Flash 2) of the getURL action, enter:
    javascript:launchwin('yourpage.html' , 'newwindow' , 'height=150,width=300')
    For each window you want to pop up, just change the filename "yourpage.html" to match the name of the file you want to appear in the new window. You can also change the height and width, or add as many extra features as are supported by the window.open method. For a list of those features, and for more information on the javascript used in the window launcher, visit javascript utopia's article on the subject.
  3. In your HTML document where your movie lives, you'll need to add the javascript with the "launchwin" function that pops up the window. Here's the code:

    
    <HTML>
    <HEAD>
    <TITLE>Your Page Title Goes Here</TITLE>
    
    <!--
    Popup Window
    Version 2.0
    Last Updated: May 7, 1999
    Code maintained at: http://www.moock.org/webdesign/javascript/
    Copy permission granted for non-commercial uses. Written by Colin Moock.-->
    
    
    <SCRIPT LANGUAGE="JavaScript"> var javascript_version = 1.0;</SCRIPT>
    <SCRIPT LANGUAGE="JavaScript1.1">  javascript_version = 1.1;</SCRIPT>
    
    
    <SCRIPT LANGUAGE="JavaScript">
    
    var newwin;
    
    function launchwin(winurl,winname,winfeatures)
    {
    	//This launches a new window and then
    	//focuses it if window.focus() is supported.
    	newwin = window.open(winurl,winname,winfeatures);
    	if(javascript_version > 1.0)
    	{
    		//delay a bit here because IE4 encounters errors
    		//when trying to focus a recently opened window
     		setTimeout('newwin.focus();',250);
    	}
    }
    </SCRIPT>
    
    </HEAD>
    
    <BODY>
    Place your movie here.
    </BODY>
    </HTML>
    
    
    

issues to consider:
Technique Two is much more stable and supported than Technique One and does not require frames or back button workarounds like Technique Three. It is the cleanest approach, however, it excludes users of IE 2.0 and IE 3.0 on pc, and IE 4.5 on macs.

recommendation:
If you're not worried about preventing those IE viewers from seeing your content, Technique Two is the easiest and most reliable way to open a new browser window from Flash.

>> to technique three

revision history
december, 1997: posted.
???, 1998: various changes i didn't have the discipline to document.
november 3, 1999: added a .zip archive containing a sample implementation of technique 2.