To open a Web page in a browser window, or to pass data to another application at the defined URL, you can use either the GetURL () global function or the Movieclip.geturl () method. For example, you can have a button linked to a new Web site, or you can send a timeline variable to a CGI script to work with the data just as you would an HTML form. You can also specify a target window, just as you would use an HTML anchor tag (<a></a>) to determine the target window.
For example, the following code opens the Adobe.com home page in an empty browser window when the user clicks the button instance named Homepage_btn:
The code is as follows |
Copy Code |
Attaching to Frames Homepage_btn.onrelease = function () { GetURL ("http://www.53dream.com", "_blank"); }; |
You can also use a GET or POST method to send a variable along with the URL. This functionality can be used if a page that is being loaded from an application server, such as a ColdFusion server (CFM) page, is expected to receive form variables. For example, suppose you want to load a CFM page named adduser.cfm with two form variables that are expected to receive name first and then age. To do this, you can create a movie clip named VARIABLES_MC that defines the two variables shown below:
The code is as follows |
Copy Code |
Variables_mc.firstname = "Francois"; Variables_mc.age = 32; |
The following code then loads adduser.cfm into the empty browser window and passes the Variables_mc.name and variables_mc.age in the POST header to the CFM page:
The code is as follows |
Copy Code |
Variables_mc.geturl ("adduser.cfm", "_blank", "POST"); |
The functionality of the GetURL () depends on the browser you are using. The surest way to make all browsers have the same functionality is to call JavaScript functions in HTML code and use the JavaScript window.open () method to open the window. Add the following HTML and JavaScript to your HTML template:
The code is as follows |
Copy Code |
<script language= "JavaScript" > <-- function Opennewwindow (myurl) { window.open (Myurl, "Targetwindow"); } --> </script> |
You can invoke Opennewwindow from the SWF file using the following ActionScript:
code is as follows |
copy code |
var Myurl: String = http://www.111cn.net; GetURL (' Javascript:opennewwindow (' + String (myurl) + '); |