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