Jump to content

Auto popup window?


fezzik

Recommended Posts

I've been looking for help with creating a automatic popup for a page. Most resources I've found only show how to implement a popup window with a link/button. I would like to have the popup launch depending on the state of a session variable. The session variable would be either true or false. I appreciate any assistance or information about other possible resources.

Cheers,

Fezzik
Link to comment
https://forums.phpfreaks.com/topic/26987-auto-popup-window/
Share on other sites

Use the onload event or some other event that you want to trigger the window with!

quick example

[code]<?php

$script = '';
$onload = '';


if ( ! $_SESSION['login'] )
{
$script = " <s c r i p t type='t e x t / j a v a s c r i p t'>
function loader()
{
w=548;
h=328;
x=(screen.width-w)/2;
y=( screen.height-h)/2;
window.open('/login.php','login','height='+h+',width='+w+',scrollbars=0,location=0,status=0,menubar=0,toolbar=0,resizable=0,left='+x+',top='+y);
}
</s c r i p t>
";
$onload = " onload='setTimeout(\"loader()\", 1200);'";
}
?>
<html>
<head>
<title>Untitled Document</title>
<?=$script;?>
</head>
<body<?=$onload;?>>
<div align='center'>test</div>
</body>
</html>[/code]


The script tags have spaces, because the forum doesn't like them...

Link to comment
https://forums.phpfreaks.com/topic/26987-auto-popup-window/#findComment-123383
Share on other sites

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.