# Javascript Error message on Window load

**URL:** <https://forum.kirupa.com/t/javascript-error-message-on-window-load/254311>\
**Category:** web dev\
**Created:** [March 10, 2008, 8:25pm UTC](https://forum.kirupa.com/t/javascript-error-message-on-window-load/254311 "2008-03-10T20:25:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pherank](https://avatars.discourse-cdn.com/v4/letter/p/4af34b/32.png) [@Pherank](https://forum.kirupa.com/u/Pherank)\
**Post date:** [March 10, 2008, 8:25pm UTC](https://forum.kirupa.com/t/javascript-error-message-on-window-load/254311/1 "2008-03-10T20:25:59Z")

</div>

Can someone help me with this script? The error message I’m getting when the popup is created: oxygenForm is not defined. The script controls two popup windows and adds a window close event.

```auto

<script language="JavaScript" type="text/javascript">
<!--
function newWindow(URL) {
     windowName = "elementForm";
    
    width = 500;
    height = 510;
    scrolling = 0;
    
    var topX = (window.screen.width / 2) - ( width / 2);
    var topY = (window.screen.height / 2) - ( height / 2);
    
    popupWindow=window.open(URL, windowName, 'width=' + width + ',height=' + height + ',location=no,resizable=yes,scrollbars=' + scrolling + ',screenX=' + topX + ',screenY=' + topY);
    // If the browser supports the focus() method place focus on the new window
    if (window.focus) { popupWindow.focus() }
    // If the Oxygen popup is visible then close it
    oxygenForm.close();
}
function oxygenPopup(URL) {
     windowName = "oxygenForm";
    
    width = 500;
    height = 760;
    scrolling = 0;
    
    var topX = (window.screen.width / 2) - ( width / 2);
    var topY = (window.screen.height / 2) - ( height / 2);
    
    oxygenWin=window.open(URL, windowName, 'width=' + width + ',height=' + height + ',location=no,resizable=yes,scrollbars=' + scrolling + ',screenX=' + topX + ',screenY=' + topY);
    //If the browser supports the focus() method place focus on the new window
    if (window.focus) { oxygenPopup.focus() }
}
//-->
</script>

```
