Jump to content

PHP/HTML Possible Java or Ajax Help!


herghost

Recommended Posts

Hi All,

 

I have this simple piece of code:

 

<?php

if(isset($_GET['update']))
{
//popup here 
}
?>

 

It just checks to see if a user has closed a window. What I want is a popup message box here when the page is loaded.

 

I have tried things like this :

<?php

if(isset($_GET['update']))
{
echo "<body onload='window.open('message.php:','Popup_Window',";
echo "'toolbar=no,location=no,directories=no,status=no,";
echo "menubar=no,scrollbars=no,resizable=no,copyhistory=no,";
echo "width=600,height=400,top=30,left=20')' >";
}
?>

 

Which just doesnt work :)

 

How would I go about this?

 

Link to comment
https://forums.phpfreaks.com/topic/154940-phphtml-possible-java-or-ajax-help/
Share on other sites

Hi mate, thanks for your reply, I have done a bit of playing around and got to this:

 

if(isset($_GET['update']))
{
echo "<script type='text/JavaScript'>function popupMsg(msg) { alert(msg);}</script>";
echo "<SCRIPT LANGUAGE='javascript'>'onLoad='popupMsg('message here')</SCRIPT>";
echo "is this working";

}

 

The is this working quote appears but nothing else happens, I am sure there is a simple way :)

if(true)
{
   echo "<script type='text/JavaScript'>function popupMsg(msg) { alert(msg);}</script>";
   echo "<SCRIPT LANGUAGE='javascript'>window.onLoad = popupMsg('message here')</SCRIPT>";
   echo "is this working";

}

This worked for me, an alert window popped up.

 

The code you have in the first line is extraneous.  You can simply make the second line be "alert" instead of "popupMsg"...

if(true)
{
   echo "<script type='text/JavaScript'>function popupMsg(msg) { alert(msg);}</script>";
   echo "<SCRIPT LANGUAGE='javascript'>window.onLoad = popupMsg('message here')</SCRIPT>";
   echo "is this working";

}

This worked for me, an alert window popped up.

 

The code you have in the first line is extraneous.  You can simply make the second line be "alert" instead of "popupMsg"...

 

A little note, if you copy paste the function as it stands here, it won't work, javascript is case sensitive so make sure you use window.onload instead of window.onLoad

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.