Javascript question

For questions and postings not covered by the other forums
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Javascript question

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:44 pm

by sbarrett >> Fri, 3 Dec 2004 2:01:46 GMT

This is a long shot - but here goes:
I'm executing the following excerp of javascript on the submit of a 'popup' window (here 'opener' is the parent browser window)
.....
window.opener.JadeForm.submit();
window.close();
return;
}
.....

In IE I find it works fine, but in Netscape Navigator v 7.xx, it fails to submit the opener, and fails to close the popup window. I can assertain the client browser type and execute different code dependant on that, but does anyone know what alternative code might work for NN?

Thanks,
Tim

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Javascript question

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:44 pm

by Tim Hollobon >> Mon, 6 Dec 2004 3:08:28 GMT

Self answered: the code needs to be

window.opener.document.forms[0].submit();

not

window.opener.jadeform.submit();

in order to be compatable with Netscape/Mozilla.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Javascript question

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:44 pm

by Stephen >> Tue, 7 Dec 2004 3:59:10 GMT

That works if you have only 1 form on the page, otherwise you need to try and keep track of which form corresponds to what number.
Eg. Home page may have one form for logon, one form for a "tell us where you are from", one for a password reminder etc...

I prefer to always use the name of the form much like you did in your first example. It makes the code much easier to read too.

window.opener.findObj("JadeForm").submit();

Where the method findObj is:

function findObj(n, d) {
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[n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers.document); return x;
}

And that doesn't matter what browser its running on. And it can be used to find a form, texbox value, checkbox, radio button selection etc...


Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 38 guests

cron