Revision [82]
Last edited on 2008-07-15 15:09:55 by GdgAdminAdditions:
=====Working with popup windows=====
//For advanced users only//
Please see the help topic about popup windows:
[[http://help.htmlexe.com/index.php?show=popupwindows.htm Popup Windows in Ebooks]]
Remember that popups are only handled by **Internet Explorer-based publications** (and Self-Extracting ones of course).
//For advanced users only//
Please see the help topic about popup windows:
[[http://help.htmlexe.com/index.php?show=popupwindows.htm Popup Windows in Ebooks]]
Remember that popups are only handled by **Internet Explorer-based publications** (and Self-Extracting ones of course).
Deletions:
//For advanced users only//
Popups (new navigation windows without menu bar, tool bar or status bar) are not officially supported because this feature requires a lot of testing, and it may also not work exactly as in Internet Explorer. However, in some cases, popups are useful (display a site contents, log in dialog...); that's why this article explains you **how to open display compiled web pages in new popups**.
First remember that popups are only handled by **Internet Explorer-based publications** (and Self-Extracting ones of course).
====How to open a popup window?====
There are several ways to open a new popup window from your HTML pages:
- with a **standard hyperlink tag**: use the target parameter **_hepopup_** followed by the name of your popup window (no space, alphanumeric characters only).
Example :
%%(html4strict)
Open popup.html in a new window
%% The popup's name will be //pop1// and this popup will show the compiled webpage named //popup.html//.
You can also use external links like http://www.htmlexe.com:
%%(html4strict)
See our website
%% Here the popup's name is //web//
- with **HEScript**: an internal HEScript procedure **Showpopup** is available and lets you specify additional parameters for your popup window.
Syntax:
%%(pascal)
procedure ShowPopup(const Name, URL: String; Width, Height, Top, Left: Integer; IsModal, RedirectLinksToMain: Boolean);
%%
**Name**: name of your popup window.
**URL**: url to the page that should be displayed. It can be a virtual path to a compiled page or a full URL.
**Width, Height**: width and height of the popup window (in pixels).
**Left, Top**: x and y screen coordinates of the top-left corner (in pixels).
**IsModal**: always set the value to false.
**RedirectLinksToMain**: whether you want the popup window to redirect all hyperlinks to the main window (when a user clicks on a link, the page is displayed in the main window). Could be useful for website contents.
Example: you could associate the following Boolean function OnMyMenuClick with a [[http://help.htmlexe.com/menueditor.htm custom menu command]] or a [[http://help.htmlexe.com/toolbareditor.htm toolbar button]].
%%(pascal)
function OnMyMenuClick: Boolean;
begin
ShowPopup("mypopup", "help/tellmemore.htm", 400, 300, 50, 25, false, true);
end;
%%
Additionally you could add the following HEScript commands to your UserMain script:
%%(pascal)
{
NewWindow: opens a new popup window.
URL : url to the page to display
WindowName: name of the popup (for targets and other functions).
width: width of the popup
height: height of the popup
top: y screen position of the popup
left: x screen position of the popup
redirect: if "1", then all links are redirected to the main window.
}
procedure NewWindow(Url, WindowName, Width, Height, Top, Left, Redirect: String);
begin
ShowPopup(WindowName, Url, StrToInt(width), StrToInt(height), StrToInt(top),StrToInt(left), false, Redirect = "1");
end;
%%
In this case, you can now display any popup you want without having to create a specific HEScript function for each popup.
To call the previous NewWindow function from your HTML pages, use:
%%(html4strict)
Open a new window
%%
- with **JavaScript**: you can use the **window.external.ShowPopup** JavaScript extension.
Syntax:
%%(javascript)
function window.external.ShowPopup(Name, URL, Width, Height, Top, Left, Param);
%%
**Name**: name of your popup window.
**URL**: url to the page that should be displayed. It can be a virtual path to a compiled page or a full URL.
**Width, Height**: width and height of the popup window (in pixels).
**Left, Top**: x and y screen coordinates of the top-left corner (in pixels).
**Param**: always set the value to 0.
Examples:
- directly in HTML
%%(html4strict)
Open a new window JS
%%
- In a script
%%(javascript)
function displaypopup(url)
{
window.external.ShowPopup('newwindow', url, 200,100,50,80,0);
}
%%
====How to close a popup window?====
You can either use the HEScript function:
%%(pascal)
procedure ClosePopup(const Name: String);
%%
or the JavaScript one:
%%(javascript)
window.external.ClosePopup(Name);
%%
To **close all popup windows**, use the HEScript function **CloseAllPopups**
%%(pascal)
procedure CloseAllPopups;
%%
====Notes====
- popup windows do not have tool bar, menu bar nor status bar. There is no navigation controls available, and their context menu is automatically disabled (you can activate it using a special command, please contact us if you want it). So your users can't use Back/Forward page navigation commands.
- when a popup is displayed, the UserMain's HEScript event **OnDisplayWindow** is fired.
- when a popup is closed, the UserMain's HEScript event **OnCloseWindow** is fired.
- avoid opening several popup windows (to save resources on old computers).
If you need help about opening popups, feel free to [[http://www.htmlexe.com/contact.htm contact the technical support]].