# Pop-up windows

**URL:** https://forum.kirupa.com/t/pop-up-windows/18736
**Category:** Uncategorized
**Created:** [April 20, 2003, 10:22am UTC](https://forum.kirupa.com/t/pop-up-windows/18736 "2003-04-20T10:22:50Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![chris9902](https://avatars.discourse-cdn.com/v4/letter/c/eb9ed0/32.png) [@chris9902](https://forum.kirupa.com/u/chris9902)
#### Post date: [April 20, 2003, 10:22am UTC](https://forum.kirupa.com/t/pop-up-windows/18736/1 "2003-04-20T10:22:50Z")

</div>

does anyone have a code for a pop window that works in all browsers

i got this:

```php

<script language="JavaScript" type="text/JavaScript">
<!--
function GP_AdvOpenWindow(theURL,winName,features,popWidth, popHeight,winAlign,ignorelink,alwaysOnTop,autoCloseTime,borderless) { //v2.0
  var leftPos=0,topPos=0,autoCloseTimeoutHandle, ontopIntervalHandle, w = 480, h = 340;  
  if (popWidth > 0) features += (features.length > 0 ? ',' : '') + 'width=' + popWidth;
  if (popHeight > 0) features += (features.length > 0 ? ',' : '') + 'height=' + popHeight;
  if (winAlign && winAlign != "" && popWidth > 0 && popHeight > 0) {
    if (document.all || document.layers || document.getElementById) {w = screen.availWidth; h = screen.availHeight;}
        if (winAlign.indexOf("center") != -1) {topPos = (h-popHeight)/2;leftPos = (w-popWidth)/2;}
        if (winAlign.indexOf("bottom") != -1) topPos = h-popHeight; if (winAlign.indexOf("right") != -1) leftPos = w-popWidth; 
        if (winAlign.indexOf("left") != -1) leftPos = 0; if (winAlign.indexOf("top") != -1) topPos = 0;                         
    features += (features.length > 0 ? ',' : '') + 'top=' + topPos+',left='+leftPos;}
  if (document.all && borderless && borderless != "" && features.indexOf("fullscreen") != -1) features+=",fullscreen=1";
  if (window["popupWindow"] == null) window["popupWindow"] = new Array();
  var wp = popupWindow.length;
  popupWindow[wp] = window.open(theURL,winName,features);
  if (popupWindow[wp].opener == null) popupWindow[wp].opener = self;  
  if (document.all || document.layers || document.getElementById) {
    if (borderless && borderless != "") {popupWindow[wp].resizeTo(popWidth,popHeight); popupWindow[wp].moveTo(leftPos, topPos);}
    if (alwaysOnTop && alwaysOnTop != "") {
        ontopIntervalHandle = popupWindow[wp].setInterval("window.focus();", 50);
        popupWindow[wp].document.body.onload = function() {window.setInterval("window.focus();", 50);}; }
    if (autoCloseTime && autoCloseTime > 0) {
        popupWindow[wp].document.body.onbeforeunload = function() {
              if (autoCloseTimeoutHandle) window.clearInterval(autoCloseTimeoutHandle);
            window.onbeforeunload = null; }  
           autoCloseTimeoutHandle = window.setTimeout("popupWindow["+wp+"].close()", autoCloseTime * 1000); }
      window.onbeforeunload = function() {for (var i=0;i<popupWindow.length;i++) popupWindow*.close();}; }   
  document.MM_returnValue = (ignorelink && ignorelink != "") ? false : true;
}
//-->
</script>

```

then you add this for a link

```php
<a href="#" onClick="GP_AdvOpenWindow('http://www.myjspace.com/user/grandtheftauto/screens/pages/1.html','newWindow','fullscreen=no,toolbar=no,locatio n=no,status=no,menubar=no,scrollbars=no,resizable=no',640,448,'center','ignoreLink','',0,'');return document.MM_returnValue"><img src="http://www.myjspace.com/user/grandtheftauto/screens/thumb/1s.jpg" alt="" border="0"></a> 

```

but i am told it only works in IE

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [April 20, 2003, 1:30pm UTC](https://forum.kirupa.com/t/pop-up-windows/18736/2 "2003-04-20T13:30:36Z")

</div>

i think this one works on all browsers

[http://javascript.internet.com/generators/popup-window.html](http://javascript.internet.com/generators/popup-window.html)

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [April 20, 2003, 1:32pm UTC](https://forum.kirupa.com/t/pop-up-windows/18736/3 "2003-04-20T13:32:15Z")

</div>

unhhh… Doesnt this work for everything:  
head:

```php
<!--
function popup(location,window_name,features) {
  window.open(location,window_name,features);
}
//-->

```

body (pop up on load, but could be on a link):

```php
<body onLoad="popup('page.html','Window Name','toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=500,height=500')">

```
