Solved

pop up windows

Posted on 2002-07-08
6
240 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Suggested Solutions

Title # Comments Views Activity
How has this flight information been added to this website? 7 31
MAILCHIMP SUBSCRIPTION LINK 2 30
Undefined variable problem 5 23
Checking https returns 301 21 26
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
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.
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…
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…

829 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