Forum Moderators: open
popupWindow(...).document body' null or not an object
Code: 0
URL: ....
May some one tell me how to fix it? the form works and the submit is done... but the error appears...
I can provide the url vía sticky.
Any help please?!
The jscript is in a js file linked (working ok)
I'll paste the html form code first, and then the code of the .js file
The html form code:
<form action="formoknewsletter.php" target="ok" method="post" name="newsletter" id="newsletter" onSubmit="GP_AdvOpenWindow('formoknewsletter.php','ok','fullscreen=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no',400,135,'center','ignoreLink','',2,'');return document.MM_returnValue" >
<table border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2"><br> <input type=hidden name="recipient" value="mailto:suscribe@killersites.com.ar">
<input type=hidden name="subject" value="Suscribe">
<input type=hidden name="redirect" value="http://www.mysite.com/formoknewsletter.htm">
<span class="smallemphasis"> Suscribe!</span></td>
</tr><tr><td><span class="smallbold">E-mail:
<input name="email" type="text" class="field" onBlur="MM_validateForm('email','','RisEmail');return document.MM_returnValue" size="25">
<input name="okbot" type="image" id="okbot" src="img/okbot.gif" alt="Enviar" align="middle" width="20" height="14" border="0">
</span></td>
<td> </td>
</tr>
</table>
</form></td>
The js file code:
// JavaScript Document
<!--
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_validateForm() { //v4.0
var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 ¦¦ p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
} else if (test!='R') { num = parseFloat(val);
if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
if (test.indexOf('inRange')!= -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (num<min ¦¦ max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
} if (errors) alert('The following error(s) occurred:\n'+errors);
document.MM_returnValue = (errors == '');
}
//-->
<!--
function GP_AdvOpenWindow(theURL,winName,features,popWidth,popHeight,winAlign,ignorelink,alwaysOnTop,autoCloseTime,borderless) { //v2.0
var leftPos=0,topPos=0,autoCloseTimeoutHandle, ontopIntervalHandle, w = 480, h = 340;
if (popWidth > 0) features += (features.length > 0? ',' : '') + 'width=' + popWidth;
if (popHeight > 0) features += (features.length > 0? ',' : '') + 'height=' + popHeight;
if (winAlign && winAlign!= "" && popWidth > 0 && popHeight > 0) {
if (document.all ¦¦ document.layers ¦¦ document.getElementById) {w = screen.availWidth; h = screen.availHeight;}
if (winAlign.indexOf("center")!= -1) {topPos = (h-popHeight)/2;leftPos = (w-popWidth)/2;}
if (winAlign.indexOf("bottom")!= -1) topPos = h-popHeight; if (winAlign.indexOf("right")!= -1) leftPos = w-popWidth;
if (winAlign.indexOf("left")!= -1) leftPos = 0; if (winAlign.indexOf("top")!= -1) topPos = 0;
features += (features.length > 0? ',' : '') + 'top=' + topPos+',left='+leftPos;}
if (document.all && borderless && borderless!= "" && features.indexOf("fullscreen")!= -1) features+=",fullscreen=1";
if (window["popupWindow"] == null) window["popupWindow"] = new Array();
var wp = popupWindow.length;
popupWindow[wp] = window.open(theURL,winName,features);
if (popupWindow[wp].opener == null) popupWindow[wp].opener = self;
if (document.all ¦¦ document.layers ¦¦ document.getElementById) {
if (borderless && borderless!= "") {popupWindow[wp].resizeTo(popWidth,popHeight); popupWindow[wp].moveTo(leftPos, topPos);}
if (alwaysOnTop && alwaysOnTop!= "") {
ontopIntervalHandle = popupWindow[wp].setInterval("window.focus();", 50);
popupWindow[wp].document.body.onload = function() {window.setInterval("window.focus();", 50);}; }
if (autoCloseTime && autoCloseTime > 0) {
popupWindow[wp].document.body.onbeforeunload = function() {
if (autoCloseTimeoutHandle) window.clearInterval(autoCloseTimeoutHandle);
window.onbeforeunload = null;}
autoCloseTimeoutHandle = window.setTimeout("popupWindow["+wp+"].close()", autoCloseTime * 1000); }
window.onbeforeunload = function() {for (var i=0;i<popupWindow.length;i++) popupWindow[i].close();}; }
document.MM_returnValue = (ignorelink && ignorelink!= "")? false : true;
}
//-->
But: please do not dump such large amounts of script here (especially not without line breaks...). Try to
debug it by rebuilding it from scratch, step by step, test at every step and see where the error creeps in.
popupWindow[wp].document.body.onload = function()
and
popupWindow[wp].document.body.onbeforeunload = function()
should be
popupWindow[wp].window.onload = function()
and
popupWindow[wp].window.onbeforeunload = function()
(I'm not 100% sure about the syntax; maybe you should leave out 'window'. You'll soon see whether it works or not ;)
I changed that, the error is gone but the
email received from the form now
doesn't contain the value of varible.
(it's just 1 field: email) and appears empty...
I'm clueless
Never though open a pop up window could be so complicated...
Do you know what the problem is?
I appreciate your help very much!