6.
How to open a popup browser window
FFish Script does not provide any method to
open a popup browser window. However, it can
be done by the WebBrowser control:
Firstly let's create a hidden browser window
and open a blank window. From [Main Menu]->[Tools]->[Insert
ActiveX controls] insert the Web Browser control:
var var1 = createControl("Shell.Explorer.2",
0, 0, 0, 0);
var1.activex.navigate2("about:blank");
|
Then let's get the window object of the opened
document.
| var window = null;
var1.activex.NavigateComplete2 = function
(obj, url)
{
var doc = obj.document;
window = doc.parentwindow;
} |
Notice: you cannot use "var1.activex.document"
before the navigating is complete. The expression
will return null for the document might not
be openned yet.
Now we can open the popup window:
var pop = window.open("about:blank",
"preview",
"height=400,width=550,status=yes,toolbar=no,scrollbar=no,menubar=no,loc
ation=no", false);
pop.document.write(html); |
If you want to open a popup window without
borders, you can use the method introduced by
http://www.jsmadeeasy.com/javascripts/Advanced/splashwin/splashwin.html
Here is the code taken from the site, we made
a little changes to make it work in FFish Script
function launchSplashWin(contentType,
contentString, width, height, left, top)
{
var w = window.screen.width;
var h = window.screen.height;
var l = (left != null) ? left : (w - width)
/ 2;
var t = (top != null) ? top : (h - height)
/ 2;
var uri = (contentType.toLowerCase()
== "uri") ? contentString :
"about:blank";
var splashWin = window.open(uri, '_splash',
'fullscreen=1,toolbar=0,location=0,directories=0,status=0,menubar=0,scro
llbars=0,resizable=0', false );
splashWin.blur();
window.focus();
splashWin.resizeTo(width,height);
splashWin.moveTo(l, t);
if (contentType.toLowerCase() == "string")
{
var swd = splashWin.document;
swd.write(contentString);
swd.close();
}
splashWin.focus();
}
|
Notice: Though the "window.open"
method takes 4 optional parameters, you must
provide all its parameters in FFish Script,
or it will say something like "wrong parameters".
We made a demo to preview the main movie in
the popup window:
1. Prepare a string contains the HTML codes
var str = '<HTML><HEAD><meta
http-equiv=Content-Type content="text/html;
charset=GB2312">';
str += '<TITLE>Preview</TITLE>';
str += '</HEAD>';
str += '<BODY bgcolor="#FFFFFF">';
str += '<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';
str += 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"';
str += 'WIDTH="550" HEIGHT="400">';
str += '<PARAM NAME=movie VALUE="SWF_NAME">';
str += '<PARAM NAME=quality VALUE=high>'
str += '<PARAM NAME=bgcolor VALUE=#FFFFFF>'
str += '<EMBED src="SWF_NAME"
quality=high bgcolor=#FFFFFF WIDTH="550"
HEIGHT="400"';
str += 'TYPE="application/x-shockwave-flash"
PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED>';
str += '</OBJECT></BODY></HTML>';
var movie = getMovies()[0];
var html = str.replace(/SWF_NAME/g, movie);
|
2. Write the string to the document of the
popup window
var pop = window.open("about:blank",
"preview",
"height=400,width=550,status=yes,toolbar=no,scrollbar=no,menubar=no,loc
ation=no", false);
pop.document.write(html);
|
|