HTML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignHTML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 1st, 2000, 02:14 PM
smmorrow smmorrow is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2000
Location: Pennsylvania, USA
Posts: 37 smmorrow User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 24 m 15 sec
Reputation Power: 9
Hope someone can help a javascript novice.

I am automatically submitting a form (hidden from the visitor) via form.submit. The form tag is coded with a target parameter, in this case 'phppage', and an action of "/check.php3".
check.php3 sets a cookie, calls itself back to make sure cookies are enabled, then redirects to another URL. Since I want this new URL (once it's been redirected to) to be in a new open window, I am also defining a window.open (url,name,features) with url of '', name of the target page 'phppage' that was defined in the form tag, and features including no toolbar and a specific width and height - along with the form submit.

I've tried putting the window.open both before and after the form.submit, but either way, it creates a new blank page (with the correct features) AND a smaller window (without the features) with the correct results (the final URL destination).

I originally tried the onsubmit in the form tag, but found out that it doesn't work if combined with a form.submit. So then I tried the window.open along with the form submit, but can't get the results I need.

Can anyone help? Is there another way to do this?

Sharon

Reply With Quote
  #2  
Old June 13th, 2000, 01:58 AM
rkmarcks rkmarcks is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Posts: 81 rkmarcks User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
Send a message via AIM to rkmarcks
How are you handling your redirect? Usually the redirect is within a META tag in the head of the document. I assume the reason you have two windows popping up is one for the window.open() function and the other for the redirect within the META tag.

Instead of redirecting from the META tag, open a new window based on what you determine from your cookie. Then do a document.write() to write some trivial code, including the META tag with the redirect, to the new window. Might look something like this:

<SCRIPT>
var trivial="<HTML><HEAD><META redirect line ><//HEAD><BODY><//BODY><//HTML>"
var features="scrollbar=no,....."
var title="mytitle"

win1=window.open('blank.htm',title,features);
win1.document.write(trivial);

</SCRIPT>

The above should write essentially a blank document to your popup including the meta tag with the redirect. Then the redirect should fire and load the requested url into the popup. At least that's the plan. Let me know if this works. This is just off the top of my head. I've used similar code for other purposes but have never written to a popup so I'm unsure of the document.write syntax in this case.

P.S. You cannot write <SCRIPT>...js...</SCRIPT> to another window this way. At least I've not been able to.

Russ

<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by smmorrow:
Hope someone can help a javascript novice.

I am automatically submitting a form (hidden from the visitor) via form.submit. The form tag is coded with a target parameter, in this case 'phppage', and an action of "/check.php3".
check.php3 sets a cookie, calls itself back to make sure cookies are enabled, then redirects to another URL. Since I want this new URL (once it's been redirected to) to be in a new open window, I am also defining a window.open (url,name,features) with url of '', name of the target page 'phppage' that was defined in the form tag, and features including no toolbar and a specific width and height - along with the form submit.

I've tried putting the window.open both before and after the form.submit, but either way, it creates a new blank page (with the correct features) AND a smaller window (without the features) with the correct results (the final URL destination).

I originally tried the onsubmit in the form tag, but found out that it doesn't work if combined with a form.submit. So then I tried the window.open along with the form submit, but can't get the results I need.

Can anyone help? Is there another way to do this?

Sharon
[/quote]


Reply With Quote
  #3  
Old June 13th, 2000, 09:06 AM
smmorrow smmorrow is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2000
Location: Pennsylvania, USA
Posts: 37 smmorrow User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 24 m 15 sec
Reputation Power: 9
Thanks for your reply, Russ. My redirect is actually happening in check.php3 - a PHP script, that does a redirect via a single statement:

header("Location: $nextpage");

Where $nextpage is the URL.

I guess I could try adding your javascript code to the php page and see what happens. Since I needed to do something quickly, I was able to initiate a new open window earlier in the process - so that the new window already existed at the time of the cookie creation and redirect, and they automatically executed in this new window. That worked. But, it would be nice to know if this will work for future projects where I may not have the luxury of opening up a new window earlier in the process. So I'll save this information and give it a try when I get the opportunity.
Again, thanks for your help.

Sharon


Reply With Quote
  #4  
Old June 28th, 2000, 08:30 AM
mmonks mmonks is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Posts: 27 mmonks User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Sharon,

I have found a way round this problem by adding 'pauses' to the javascript. This essentially gives the popup window time to load fully before the form is submitted to it. The code I was using when I was having the problem was similar to this -

window.open('','CallMePopUp','status=no,etc');
document.form.target='CallMePopUp';
document.form.submit();

This was getting exactly the same problem you described i.e. 2 windows were opening - a blank popup and a new browser window containing the submitted form. However, I found that by using the 'setTimeout' javascript function I could delay the submission of the form slightly so that when it was submitted the popup window was fully loaded and had been recognised as the target.

So the code that works looks like this -

window.open('','CallMePopUp','status=no,etc');
var set_timeout1=setTimeout("document.form.target='CallMePopUp';",100);
var set_timeout=setTimeout("document.form.submit();",200);

This basically delays setting the form target for 100 millisecs and the submission of the form by 200 millisecs, and seems to work (at least in IE4/5, NN4/5 for Windows).

Hope that helps,
Matt.


<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by smmorrow:
Hope someone can help a javascript novice.

I am automatically submitting a form (hidden from the visitor) via form.submit. The form tag is coded with a target parameter, in this case 'phppage', and an action of "/check.php3".
check.php3 sets a cookie, calls itself back to make sure cookies are enabled, then redirects to another URL. Since I want this new URL (once it's been redirected to) to be in a new open window, I am also defining a window.open (url,name,features) with url of '', name of the target page 'phppage' that was defined in the form tag, and features including no toolbar and a specific width and height - along with the form submit.

I've tried putting the window.open both before and after the form.submit, but either way, it creates a new blank page (with the correct features) AND a smaller window (without the features) with the correct results (the final URL destination).

I originally tried the onsubmit in the form tag, but found out that it doesn't work if combined with a form.submit. So then I tried the window.open along with the form submit, but can't get the results I need.

Can anyone help? Is there another way to do this?

Sharon
[/quote]


Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignHTML Programming > form.submit to new window


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway