Image

Imagefusion260 wrote in Imagejavascript 😦tired

Listens: Office chatter

Popup woes [SOLVED]

Greetings everyone! I'm having an issue with a script I wrote that will do three things:

1) Detect whether or not a popup with the name of 'radioWindow' is open
2) If so, it'll just bring it to focus or pass it a variable
3) If not, it'll open the window

So, I'm posting what I wrote below, and I'm getting an error, of course. The browser (IE 6 SP2) is reporting that the window is undefined and will not proceed with the script, however, this was based off an example I've seen on a number of Javascript sites. Firefox just doesn't do anything at all, including showing errors.

Any help would be greatly appreciated!
This has been solved, thanks to blogbaron!


function loadRadio(djName) {
  //CHECK TO SEE IF RADIO IS OPENED
  if (radioWindow != "undefined") {
    if (!radioWindow.closed) {
      if (djName != "undefined") {
        //IF djName PASSED, CALL FUNCTION IN RADIO WINDOW
        alert('Loading '+djName+' into DJ Radio');
        window.radioWindow.loadDJ(djName);
      } else {
        //OTHERWISE JUST FOCUS RADIO WINDOW
        window.radioWindow.focus();
      }
    } else {
      //OPEN RADIO
      alert('Launching Radio');
      var winl = (screen.width - w) / 2;
      var wint = (screen.height - h) / 2;
      winprops = 'height=495,width=370,top='+wint+',left='+winl+',scrollbars=no,menubar=no,status=no,fullscreen=no';
      radioWindow=window.open('radio.htm','radioWindow',winprops);
    }
  }
}