Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > Preventing redirect after submit - showing result in new window

Reply
Thread Tools

Preventing redirect after submit - showing result in new window

 
 
Fernie
Guest
Posts: n/a
 
      11-19-2004
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




--

ELKNews FREE Edition - Empower your News Reader! http://www.atozedsoftware.com
 
Reply With Quote
 
 
 
 
rf
Guest
Posts: n/a
 
      11-19-2004
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.

--
Cheers
Richard.


 
Reply With Quote
 
 
 
 
Fernie
Guest
Posts: n/a
 
      11-19-2004
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



--

ELKNews FREE Edition - Empower your News Reader! http://www.atozedsoftware.com
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
1. Ruby result: 101 seconds , 2. Java result:9.8 seconds, 3. Perl result:62 seconds Michael Tan Ruby 32 07-21-2005 03:23 PM
submit the form data to the popup window without a submit button jrefactors@hotmail.com HTML 2 01-01-2005 06:07 AM
Preventing Multiple submit (Disabling Submit Button Post Click) Solution Mark ASP .Net 1 12-13-2004 08:03 PM
Basic Q - Response.Redirect, all redirect to first Response.Redirect statement Sal ASP .Net Web Controls 1 05-15-2004 03:46 PM
Disable Submit Button until Accept Terms and Redirect Page on Submit Paul Oakfleet Javascript 1 09-10-2003 06:07 PM



Advertisments