javascript - Display Background Color before Popup? -
i set background color of green before alert pops up.. how do this?
<meta http-equiv="content-type" content="text/html; charset=utf-8"> <head><meta charset="utf-8" /> <style> html, body{ background: #0f0; } </style> </head> <title>hi there!</title> <script language='javascript'> window.alert('hello there!') </script>
i thought trick alert pops on white page
use this:
<html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <meta charset="utf-8" /> <title>hi there!</title> <style> body{ background: #0f0; } </style> <script> function showmessage() { window.alert('hello there!') } </script> </head> <body onload="showmessage();"> .. </body> </html>
note onload
attribute in body
tag. value of attribute javascript code executed once page loaded (css, images, etc).
and if want delay, change showmessage
function this:
function showmessage() { var secondsdelay = 5; //5 seconds settimeout(function() { window.alert('hello there!'); }, secondsdelay * 1000); }
Comments
Post a Comment