I’d like to set up an alert message that appears at the top of my application on the first time a user accesses it, and persists until the user dismisses it.
I’m kinda new to jQuery, but I’d like to use it for this. Does jQuery have some built in methods for this kind of thing? Ideally I’d like it to be an instant action, rather than a form variable.
My app is a PHP based WordPress plugin.
You can create a twitter-like alert by following the steps on these tutorials.
CSS:
jQuery
Check if
Use setTimeout to collapse the alert after 3 seconds
Expand the alert to CSS line-height or 50px if line-height is not set
If the user clicks alert before 3 seconds, collapse the alert early
Put CSS and jQuery in an HTML page
Some things to note:
Line 1: Turn on session with PHP
Line 13: There’s our alert CSS
Line 30: If $_SESSION[‘alert’] exists (set in submit.php in step 2)
Line 40: Use jQuery hosted by Google
Line 42: There’s our alert jQuery
Use PHP to add the alert to the $_SESSION
Save this file as submit.php
It will create something similar to this
http://www.youtube.com/watch?v=BbJeYdPRKXw&feature=player_embedded
Comment below if you have any questions on the code, I guess this is all you need.
Credits to:
http://briancray.com/2009/05/06/twitter-style-alert-jquery-cs-php/
http://www.achari.in/create-twitter-alert-style-using-jquery-js-and-css