Jump to content

Recommended Posts

Is it possible to do a purely PHP popup message box?

 

I cant seem to find one that doesnt involve java or ajax!

 

Basically I have this:

 

if(isset($_GET['update']))
{

                                                                                                                                                                                                                                        
echo "thanks for registering, you may now login";

}

 

and I want the text to pop up in a box?

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/155112-solved-php-popup/
Share on other sites

Thanks,

 

I have tried putting a javascript query in here, but I cant work out how to do it with php, any pointers?

 

I have tried this:

 

if(isset($_GET['update']))
{
echo "<SCRIPT LANGUAGE='javascript'>window.onload=function(popupMsg('message here'));</SCRIPT>";
                                                                                                                                                                                                                                        


}

 

and calling this in the header

 

function popupMsg(msg) 
{ 
  alert(msg);
}

 

but to no avail

Link to comment
https://forums.phpfreaks.com/topic/155112-solved-php-popup/#findComment-815954
Share on other sites

I tried this and it works

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<?php
if(isset($_GET['update']))
{
   echo "<SCRIPT LANGUAGE='javascript'>window.onload=alert('message here');</SCRIPT>";
}
?>
</head>

<body>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/155112-solved-php-popup/#findComment-815978
Share on other sites

Just fixing outdated code.

 

   echo "<script type='text/javascript'>window.onload=alert('message here');</script>";

 

The language attribute has been depreciated for a while. It is better to use the type="text/javascript" for correct markup etc. Why even add the window.onload? Just simply calling alert would work.

Link to comment
https://forums.phpfreaks.com/topic/155112-solved-php-popup/#findComment-815998
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.