Solved

pop up windows

Posted on 2002-07-08
6
241 Views
Last Modified: 2013-11-28
Can pop up windows be done in PHP?  If so, how?
0
Comment
Question by:ironfingers
  • 2
  • 2
6 Comments
 
LVL 7

Accepted Solution

by:
axis_img earned 50 total points
ID: 7139630
No. PHP is processed on the server _BEFORE_ it is sent to the user. New browser windows have to be done with javascript. You can use PHP to print out the javascript for a popup window though, just in case you wanted something in the javascript to be dynamic. Something along the lines of:

<?
$file            = "page.html";
$width           = 500;
$height          = 400;

$js_string       = "<script language='javascript'>\n";
$js_string      .= "<!--\n";
$js_string      .= "var win = window.open('" . $file . "', 'newwin', 'width=" . $width . ",height=" . $height . "');\n";
$js_string      .= "//-->\n";
$js_string      .= "</script>\n";

print($js_string);
?>


Let me know if you have any other questions...
Barry
0
 
LVL 5

Expert Comment

by:dkjariwala
ID: 7140441
Barry why you want do print those statements using PHP ?
I mean you can simply do,

<html>
<head>
<script language="javascript">
window.open("page.html",'windowname','width=300,height=300');
</script>
</html>

<?php
//your php code can go here.

?>

JD
0
 
LVL 7

Expert Comment

by:axis_img
ID: 7140907
Hi JD...

You don't have to use PHP for this at all. The question was "Can pop up windows be done in PHP?  If so, how?" The question as it is asked makes me assume that he knows HOW to open new windows in Javascript, and is asking if he can do it in PHP as well.

The answer is "No", which I stated. It seemed that ironfingers was asking this for a reason, so I am simply explaining to him that you can use PHP to print out the javascript code to do the new window. You obviously wouldn't use PHP to print out the simple javascript window.open example I gave, but it was simply for example purposes. It is meant to show that you can create dynamic javascript strings for your pages.

If I misunderstood, then I am sorry. You would obviously not use PHP to print out javascript all the time, but there are some cases where it is needed, which is what I was trying to show. I thought that was the question at hand.

Regards,
Barry
0
 
LVL 5

Expert Comment

by:dkjariwala
ID: 7143119
Hm..yeah true.

I guess question was asking for clarification

JD
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A great marketing strategy is diverse.  Read about the not so popular, yet effective, marketing tactics you can start using today!
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question