Recipe 7.14. Opening Browser Windows with Specific Parameters Using Static TextProblemYou want to open a new browser window with specific dimensions (and/or other settings) when the user clicks the static text. SolutionApply a hyperlink to the text (see Recipe 8.12) in which the URL is in the form of javascript:void(window.open('url', '', 'additional parameters'));. DiscussionYou can invoke JavaScript functions from links associated with static text fields. This technique is applicable only when you have embedded the SWF in an HTML page, and it allows you to call any function that is accessible from within the HTML page, including the window.open( ) JavaScript method that opens a new browser window. To create the link, select the text and add a value to the URL link field in the form of javascript:void(window.open('url', 'window name (exp 3pod.com)', 'additional settings'));. The javascript protocol lets Flash know that you want to invoke a JavaScript function. The void( ) function should enclose the remainder of the command in order to avoid undesirable results, such as extra new windows being opened unexpectedly. Notice that the parameters for the window.open( ) method are in single quotes rather than double quotes. You should always use single quotes when you use this technique. Double quotes will not work properly. The first parameter that you pass to the window.open( ) method should be the URL you want to open in the new browser window. The value can be either an absolute URL (e.g., ) or a relative URL (e.g., /fcb). The second parameter specifies the name (exp 3pod.com) of the new window. The name (exp 3pod.com) is a way that one browser window can communicate to another. You can specify a name (exp 3pod.com) that you make up, or you can even simply use an empty string (two single quotes without any other characters in between). The third parameter allows you to tell the browser application (IE, Netscape, Safari, Opera, and so on) what settings to use with the new window. For example, you can tell the browser to open the new window with specific dimensions. The following are some of the more common settings you can specify:
Specify the settings as a comma-delimited list for the third parameter. The following is an example of the entire value you can enter for the URL field in the Property inspector. The example would cause Flash to call a JavaScript method that opens a new browser window with width and height of 100 x 100: javascript:void(window.open('http://www.person13.com/fcb', '', 'width=100,height=100')); |
Tripod >> 3pod Tips & Learning and manuals for educations