M
Mark Stafford
I want to use a pop-up dialog for my intranet, but I'm missing
something that keeps me from getting along with NS's browsers right
now.
I get an error to the effect of "opener.formName has no properties"
The following JS is its own file included in caller.html and
callee.html with this syntax <SCRIPT language="JavaScript"
src="pops.js"></SCRIPT>
It works in current IE's on multiple platforms and in Apple's Safari.
Any ideas about how I might work it for NS?
Thanks,
Mark
// <pops.js>
var DEBUGGING=false;
var myTarget=null;
function popUp(argURL, argOBJ, argH, argW) {
/* Useage example from caller.html:
<FORM name="stockForm">
<INPUT name="txtA" type="text" id="txtA" value="" size="10" />
<INPUT name="btnA" type="button" id="btnA"
onClick="popUp('callee.html', this)" value="." /><BR />
</FORM>
*/
try {
// default to 300x300, otherwise use options offered
argH=(!argH || argH==0) ? 300 : argH;
argW=(!argW || argW==0) ? 300 : argW;
// establish error message in case something goes wrong
var Err = new Error();
Err.message="mcs.js popUp(" + argURL + ", " + argOBJ.name + ", " +
argH + ", " + argW + ") error:\n\nmyTarget not established or window
not opened";
// set aside the name of the object which will be receiving the
value chosen in the popUp window
// presumes usage from naming as used above txtA and btnA
myTarget=argOBJ.form.name+'.'+'txt'+argOBJ.name.substr(3,
argOBJ.name.length-3);
if (DEBUGGING) alert('myTarget='+myTarget);
// open the popUp
listWin=window.open(argURL, 'list', 'height='+argH+',
width='+argW+', left =100, top=100, location=no, menubar=no,
resizable=yes, scrollbars=yes, status=no, toolbar=no');
// complain if it didn't work
if (myTarget==null || !listWin) throw(Err);
}
catch (Err)
{ alert(Err.message); }
}
function popDown(argVAL) {
/* Useage example from callee.html:
<A href="#" onClick="popDown('AMZN')">AMZN</A>
*/
try {
// establish error message in case something goes wrong
var Err = new Error();
Err.message="mcs.js popDown("+argVAL+") error:\n\nmyTarget not set";
var evalMe="opener."+opener.myTarget+".value="+"'"+argVAL+"'";
if (DEBUGGING) alert('evalMe='+evalMe);
eval(evalMe);
// if myTarget != val then complain
if (eval("opener."+opener.myTarget+".value!="+"'"+argVAL+"'"))
throw(Err);
else window.close();
}
catch (Err)
{ alert(Err.message); }
}
// </pops.js>
something that keeps me from getting along with NS's browsers right
now.
I get an error to the effect of "opener.formName has no properties"
The following JS is its own file included in caller.html and
callee.html with this syntax <SCRIPT language="JavaScript"
src="pops.js"></SCRIPT>
It works in current IE's on multiple platforms and in Apple's Safari.
Any ideas about how I might work it for NS?
Thanks,
Mark
// <pops.js>
var DEBUGGING=false;
var myTarget=null;
function popUp(argURL, argOBJ, argH, argW) {
/* Useage example from caller.html:
<FORM name="stockForm">
<INPUT name="txtA" type="text" id="txtA" value="" size="10" />
<INPUT name="btnA" type="button" id="btnA"
onClick="popUp('callee.html', this)" value="." /><BR />
</FORM>
*/
try {
// default to 300x300, otherwise use options offered
argH=(!argH || argH==0) ? 300 : argH;
argW=(!argW || argW==0) ? 300 : argW;
// establish error message in case something goes wrong
var Err = new Error();
Err.message="mcs.js popUp(" + argURL + ", " + argOBJ.name + ", " +
argH + ", " + argW + ") error:\n\nmyTarget not established or window
not opened";
// set aside the name of the object which will be receiving the
value chosen in the popUp window
// presumes usage from naming as used above txtA and btnA
myTarget=argOBJ.form.name+'.'+'txt'+argOBJ.name.substr(3,
argOBJ.name.length-3);
if (DEBUGGING) alert('myTarget='+myTarget);
// open the popUp
listWin=window.open(argURL, 'list', 'height='+argH+',
width='+argW+', left =100, top=100, location=no, menubar=no,
resizable=yes, scrollbars=yes, status=no, toolbar=no');
// complain if it didn't work
if (myTarget==null || !listWin) throw(Err);
}
catch (Err)
{ alert(Err.message); }
}
function popDown(argVAL) {
/* Useage example from callee.html:
<A href="#" onClick="popDown('AMZN')">AMZN</A>
*/
try {
// establish error message in case something goes wrong
var Err = new Error();
Err.message="mcs.js popDown("+argVAL+") error:\n\nmyTarget not set";
var evalMe="opener."+opener.myTarget+".value="+"'"+argVAL+"'";
if (DEBUGGING) alert('evalMe='+evalMe);
eval(evalMe);
// if myTarget != val then complain
if (eval("opener."+opener.myTarget+".value!="+"'"+argVAL+"'"))
throw(Err);
else window.close();
}
catch (Err)
{ alert(Err.message); }
}
// </pops.js>