Simple JavaScript popup window

Posted by 6bytes at 19 April 2008

Category: JavaScript

Tags:

Over the years I used a lot of JavaScript functions to open PopUp windows. Some time ago I wrote this simple function and I use it everywhere where I need to open a new window.
Add the following to your JavaScript file or embed it in the tag somewhere on your website:

function popUp(strURL, strName, strType, strTop, strLeft, strWidth, strHeight) {
var strOptions = "";
if (strType == "console") strOptions = "resizable, top="+strTop+", left="+strLeft+", width="+strWidth+", height="+strHeight;
if (strType == "fixed") strOptions = "status, top="+strTop+", left="+strLeft+", width="+strWidth+", height="+strHeight;
if (strType == "elastic") strOptions = "toolbar, menubar, scrollbars, resizable, location, top="+strTop+", left="+strLeft+", width="+strWidth+", height="+strHeight;
var newWin = window.open(strURL, strName, strOptions);
newWin.focus();
}

and to run it simply write:

your link

You need to create file.php file first. You can easily pass variables to this file like that:

your link

Enjoy!

Leave a Reply

Leave a Reply
  • (required)
  • (required) (will not be published)