Link to home
Start Free TrialLog in
Avatar of juriaan
juriaan

asked on

Close popup from parent window

Hi
I have a php script which checks if a domain is still available. It chechs more then 25 extensions and therefore it take about 10-15 seconds to load.

I want to show a popup with the text -> this will take 10-15 seconds to load please wait. If the php script is ready it has to close the popup.

To open the popup i have used:

<script>
function Openpopup2(newin) {
var venster=window.open(newin,"venster","resizable=no,scrollbars=no,width=250,height=400,top=200,left=200");
          venster.focus();
}
</script>

<form action='template.php?cat=services&content=check' method="post" onclick="javascript:Openpopup2('popupcheck.php')">
<input type='text' name='domein' value='domein'>
<input type='submit' value='start'>
</form>

It opens the popup correctly.
But can anyone give me a hint how to close the popup from php?


ASKER CERTIFIED SOLUTION
Avatar of pcaylor
pcaylor

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Exactly.

And a VERY easy 500!

Closing windows (as in opening windows) actually happens only on the client.

PHP code cannot directly open/close windows.

Instead, you would use JavaScript to do this.

JavaScript is NOT Java.

I repeat.

JavaScript is NOT Java.

JavaScript is supported by all the modern browsers (and some not so modern ones too!).

NOTE: Some people do not like popups and run software which will remove them when they load. Under normal circumstances this is not too much of a problem.

Another way to do what you want would be to use DHTML on a single page.

Start off with ...

<div id="waiting">Waiting</div>
<div id="completed" style="visible : hidden">Completed</div>

NOTE: I'm not a CSS expert, but you can "hide" bits.

At the bottom of the page, i.e. where you were thinking of window.close(...);, something like

completed.visible = true;

Not sure on the actual code, but no popups and a very different way!

Richard.
Avatar of Jonza
Jonza

isn't it visibility: hidden??
i'm not sure but...??
It is something like this. (Just consulting the MS HTML Help documentation ...)

Yep.

visibility:hidden

and

visibility:visible

So...

<div id="waiting" style="visibility:visible;">Waiting</div>
<div id="completed" style="visibility:hidden;">Completed</div>


at the top and at the bottom ...

<script language="JavaScript"><!--
waiting.style.cssText = 'visibility:hidden;';
completed.style.cssText = 'visibility:visible;';
//--></script>

should do the trick.

Richard.
or ...

<script language="JavaScript"><!--
waiting.style.visibility = 'hidden';
completed.style.visibility = 'visible';
//--></script>

Richard.
but that trick doesn't work with older browsers...

so you need to close a popup when all the PHP code have been executed?

Couldn't you use PHP for determining when the code is ready.. Put the code:
print("<script type='text/javascript'>window.close(newin);</script");

after your domain check loop and then the PHP should print the window.close after all the domain check is done?
Older sites are an issue, but so what. I have done 15 sites.

Over 95% of the hits on all the sites are IE5+

Over 98% of the hits on all the sites are IE.

Netscape/Opera/WebTV are now so minimal, that support for them is a headache.

Just because Betamax video players exists doesn't mean we can still buy tapes for them.

The browser war has been won by Microsoft. Move on.

Richard.
RQuading..
The most reliable way still is to use PHP.
why use some other technique when you can close the window automatically after PHP has been executed.

and you are saying that almost everyone uses IE..
Well the procents are true but did you know that many corporations does only have netscape 4.x browsers. Thats pretty stupid actually but you still want the corporations and their workers to browse your site, right?
I don't stop them from browsing the site.

The JavaScript method is fine and will work on a lot of browser versions.

My CSS method was an alternative. In my opinion, it is "better" as far as a popup is bloody irritating and if you run anti-popup software, there may be consequences to the site's code (errors on page sort of thing).

CSS is supported by a LOT of browsers so the number of users NOT getting this is probably very small.

Another way is to use both, but only the popup if the browser is old and doesn't support the CSS method.

Richard.