Preventing redirect after submit - showing result in new window

F

Fernie

I am submitting data using Javascript as follows:
...
f.submit();
f.target="_blank";

My problem is that I don't know how to keep the original page from showing
the cgi result. Please see the following example and you will see exactly
what I mean:

http://66.235.178.180/

I would sincerely appreciate it if someone could help me so that the
original page does not change.

Thank you
 
R

rf

Fernie
I am submitting data using Javascript as follows:

You shouldn't be. What is wrong with simply letting the browser submit the
form. That is what forms are for.
...
f.submit();
f.target="_blank";

This is incorrect. See below.
My problem is that I don't know how to keep the original page from showing
the cgi result. Please see the following example and you will see exactly
what I mean:

http://66.235.178.180/

I would sincerely appreciate it if someone could help me so that the
original page does not change.

Consider what happens when a viewer presss that submit button.

Your onSubmit handler is called. This calls function sendForm which does a
couple of things and submits the form, with f.submit(). That's right, the
form is submitted at this point. The results of this submit will appear in
*this* page.

Then the sendForm changes the target of the form. Control then passes back
to the onSubmit handler which does *not* return false. This indicates to the
browser that the form submit should proceed. The browser submits the form
again, this time with target="_blank". You get two hits on the server and
two pages returned.

Why are you doing this anyway? If your viewer has popup windows disabled
they will never see the second window.

If you insist on using a popup window then what is wrong with letting the
browser submit the form normally but specify target="_blank" in the form.
You seem to be jumping through all sorts of javascript hoops to make the
browser do what it can do anyway :)

The fix to your hoop is to reverse the order of the two lines above and to
return false from the onSubmit handler.

BTW you are using some IE specific things in there. There is a very good
chance this page will break in other browsers.
 
F

Fernie

Richard,

Thank you for responding and for your explanations. I played around with
your suggestion below but I could not figure out how to implement it.
The fix to your hoop is to reverse the order of the two lines
above and to return false from the onSubmit handler.

I've decided to take your advise and let the browser just submit the form
the way its supposed to. I'm extremely weak with front-end stuff like html
and javascript. I didn't realize that I'd be up for such a fight to get the
behavior that I mentioned in my original post.

Best Regards,

Fernie
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top