0

A library I am using gets a reference to the main window by adding this script to a popup window: var winMain=window.opener;

This script lets the popup window access global variables from the window that opened it. Example:

<select name=MonthSelector onChange="javascript:winMain.Cal.SwitchMth(this.selectedIndex);winMain.RenderCal();">

However this leaves me in an awkward position if I try to call some of these variables without opening a new window. (For instance, if I try to embed one of the calendars inside a div instead of a new window.)

  onChange="javascript:Cal.SwitchMth(this.selectedIndex);"

and

  var winMain=window;
  onChange="javascript:winMain.Cal.SwitchMth(this.selectedIndex);"

Both don't seem to work. Is there some way to get the current window's handle as a variable? Or an I just doing something wrong?

This question appears similar to mine, but the answers don't work.

Community
  • 1
  • 1
Holtorf
  • 1,451
  • 4
  • 21
  • 41

2 Answers2

2

change it to

var winMain = window.opener || window;

It says is there is no window.opener, use window.

epascarello
  • 204,599
  • 20
  • 195
  • 236
0

A window.open equivalent is below

var w = window.open('', '', 'width=400,height=400,resizeable,scrollbars');
w.document.write('Content goes here');
w.document.close();

Use it according to your need.

Kirk
  • 16,182
  • 20
  • 80
  • 112