/JavaScript

Simple JavaScript popup window

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 <script type="text/javascript"></script> 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:

<a href="/file.php" onclick="popUp('https://some_url', 'frame name', 'console', 100, 100, 300, 300)">your link</a>

You can easily pass variables to this file like that:

<a href="/file.php?id=9" onclick="popUp('https://some_url', 'frame name', 'console', 100, 100, 300, 300)">your link</a>

Enjoy!