Solved

pop up windows

Posted on 2002-07-08
6
233 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Hm..yeah true.

I guess question was asking for clarification

JD
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Read about why website design really matters in today's demanding market.
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
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 count occurrences of each item in an array.

763 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now