[prog] Popup in PHP or Javascript

tiera at bredband.net tiera at bredband.net
Tue Apr 11 01:15:47 EST 2006


On Sun, Apr 09, 2006 at 06:46:47PM -0500, Kathryn Hogg wrote:
> 
> <meta HTTP-EQUIV="Refresh" CONTENT="15 ; URL=your_second_url">
> 

I have some calculations that need to be made before the popup is
opened. It seems wrong to guess how long they will take. Does the
above really open a popup?

On Sun, Apr 09, 2006 at 06:59:17PM -0700, Julie Bovee Hill wrote:
> A simpler alternative that should also work but requires the page reload:
> 
> 1. user fills out form
> 2. user clicks a button that POSTs data to 1st php script
> 3. server sends back result
> 4. as the original page reloads, an onLoad event in the <body> tag
> invokes Javascript that opens a popup with the URL of the 2nd php
> script (a GET) with necessary data from 1st POST in the query string
> 5. popup loads with result page from 2nd php script
> 
> As I recall, loading pop-ups with non-static result data is
> hazard-prone, but everyone does it anyway. Keep in mind that the
> server could hang or timeout and nothing loads into your popup, or you
> can have the thrill of seeing a server error page all scrunched up
> inside of your popup, etc., so code defensively with lots of error
> condition checking to avoid embarassment.

Yes, I've actually thought about this. So I'm thinking about changing
the behaviour totally. The thing is that depending on a filled in
value in the form, the popup is needed or not. So perhaps it's
possible to do something like this:
1. User fills out form
2. User clicks submit
3. Some javascript activated by the onclick-method checks to see if
the popup needs to be opened or not (this must be possible, right?).
4. If the popup isn't necessary the form is post:ed to the same php
script again.
5. If the popup is necessary the popup is opened and the form is
post:ed there. And then I do all the necessary calculations in the
popup instead. 

Perhaps this is the better solution, because if the popup isn't opened
(popup blocker or other reason) no harm is done. The user can just try
to click the button again. 
 
> There a quite a few Ajax libraries out there that do the most
> complicated Javascript stuff for you. Here are a couple of links I
> begged off my S.O. who's more knowledgeable about Javascript/Ajax
> things than I am these days (but neither of us are experts). I hope
> they help:
> 
> http://www.litfuel.net/mybic/index.html?page=index
> http://www.modernmethod.com/sajax/index.phtml

Thanks, I will take a look at these.

/Tiera


More information about the Programming mailing list