Popup window with PHP?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hvlav79
Forum Newbie
Posts: 2
Joined: Tue Aug 24, 2004 6:55 pm

Popup window with PHP?

Post by hvlav79 »

Hi guys. I need some help writing a code that will open a popup window automatically, as soon as a function is completed. I want to write it in PHP without using javascript. Is that possible? If not, how would I write it using javascript?
Thanks in advance!
User avatar
Bill H
DevNet Resident
Posts: 1136
Joined: Sat Jun 01, 2002 10:16 am
Location: San Diego CA
Contact:

Post by Bill H »

PHP is server side, while popups are client side, so you need javascript.
Within the <head> tag:

Code: Select all

<SCRIPT LANGUAGE=JAVASCRIPT TYPE="TEXT/JAVASCRIPT">
     function firstWindow(report,winht,winwth)
     &#123;
          var windowX = (screen.width/2)-(winwth/2);
          s = "top=170,left="+windowX+",width="+winwth+",height="+winht;
          reportWindow = window.open(report, 'reportWin',s)
          reportWindow.focus()
     &#125;
</script>
To popup the window:

Code: Select all

<a href="javascript:firstWindow('filename.php',385,380)">click here</a>
The call defines the size of the popup window.
Post Reply