in reply to Calling a js function from within a cgi script to open a window

Above

print $query->start_html(-title => 'Selection ', -BGCOLOR=>'lavender', -script=>$JSCRIPT);
add
if ($query->param('embedvar')) { $JSCRIPT .= 'windo("no_win");'; }

Untested.