My friend’s company has recently been hit by frauds claiming to be her franchises. To protect her company and image she asked me to code a notification for her site.
However announcements like theses are kind of ugly and irritating after a while and also nowadays browsers block out popups for browsers so we can’t put it into another page.
Download the code: Div announcement script demo code
The code for your DIV
<div style=”height:570px; width:440px; border:1px solid #DDD; padding:8px; top:10px; left:50%; margin-left:-220px; position:absolute; background-color:#FFFFFF;” id=”announcement“>My Announcement goes here</div>
The red attributes can be modified to your required id/height/width. Also note the “margin-left” should be set to exactly HALF of the width that you changed, that would bring the announcement into the center of the screen.
The code for closing the DIV (Button)
<input type=”button” onclick=”document.getElementById(‘announcement‘).style.display=’none’;” value=”Close announcement”/>
Make sure the getElementById is your DIV id for the main announcement.
The PHP for loading the DIV at first visit. This needs to be place before any output on your script (ie before <html>).
//Part 1 placed before any output on screen.
The 2nd part of the script should be placed any where near the top after the body block.
//Part 2 Announcement code
INSERT YOUR ANNOUNCEMENT DIV CODE HERE.
} //End if