|
These examples demonstrate how to open popup windows,
To use it on your own page:
Before downloading the page please register. There is no registration fee, I only want to know who are interested, and I may send a note if new version is available. |
Explanation
The main function uses the window.open JavaScript function after some error checking.
ScreenX and ScreenY are for Netscape Navigator, left and top are for Microsoft Internet Explorer.
// Main function. Works on both MSIE and NN.
// Parameters:
// url : Address of popup
// x, y : Upper left corner coordinates
// w, h : Window size
function popup(url, x, y, w, h) {
if (x==undefined || x=="") x="0";
if (y==undefined || y=="") y="0";
if (w==undefined || w=="") w="100";
if (h==undefined || h=="") h="100";
win = window.open(url, "_blank",
"menubar=no,toolbar=no,location=no,directories=no,status=no," +
"copyhistory=no,resizable=no,scrollbars=no," +
"ScreenX=" + x + ",left=" + x + "," +
"ScreenY=" + y + ",top=" + y + "," +
"width=" + w + "," +
"height=" + h);
win.focus();
return win;
}
|
Calling the funcion when the main window loads is very simple:
popup("pop1.html",100,100,150,160);
|
window.SetTimeout is used to call the function 5 seconds later:
window.setTimeout("popup('pop1.html',250,100,150,160)",5000);
|
When the user clicks on the button, the parameters are extracted from the form:
<input type="button" name="Click" value="Click here to open popup"
onClick=popup("pop1.html",mForm.x.value,mForm.y.value,mForm.w.value,mForm.h.value)>
|
The mouseOver event is enclosed in <a> tags to support Netscape Navigator:
<a onMouseOver=popup("pop1.html",mForm.x.value,mForm.y.value,mForm.w.value,mForm.h.value)>
<img src="Ball.gif"></a>
|