forked from as3/as3-utils
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathopenWindow.as
More file actions
38 lines (33 loc) · 1.55 KB
/
openWindow.as
File metadata and controls
38 lines (33 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package utils.location {
import flash.external.ExternalInterface;
import flash.net.URLRequest;
import flash.net.navigateToURL;
/**
* Open a new browser window and prevent browser from blocking it.
* Based on script by Sergey Kovalyov (http://skovalyov.blogspot.com/2007/01/how-to-prevent-pop-up-blocking-in.html)
* Based on script by Jason the Saj (http://thesaj.wordpress.com/2008/02/12/the-nightmare-that-is-_blank-part-ii-help)
* Original: http://apdevblog.com/problems-using-navigatetourl
* You also have to set the wmode inside your containing html file to "opaque" and the allowScriptAccess to "always".
* @param url url to be opened
* @param window Window target
* @param features Additional features for window.open function
* @author Sergey Kovalyov
* @author Jason the Saj
* @author Aron Woost (<a href="http://apdevblog.com">apdevblog.com</a>)
* @author Philipp Kyeck (<a href="http://apdevblog.com">apdevblog.com</a>)
*/
public function openWindow(url:String, window:String = "_blank", features:String = ""):void {
switch(getLocationName()) {
case locationNames.BROWSER_FIREFOX:
ExternalInterface.call("window.open", url, window, features);
break;
case locationNames.BROWSER_IE:
ExternalInterface.call("function setWMWindow() {window.open('" + url + "');}");
break;
default:
// otherwise, use Flash's native 'navigateToURL()' function to pop-window.
// this is necessary because Safari 3 no longer works with the above ExternalInterface work-a-round.
navigateToURL(new URLRequest(url), window);
}
}
}