This script is working but it loads only after the whole page is loaded. Can anyone modify this script in such a way that it prompts before loading the site.
<html><head><title>mex</title>
<script type="text/javascript">
<!--//
function doWelcome() {
var dc = document.cookie;
if(dc.length > 0) {
document.getElementById('welcome').innerHTML = 'Welcome back '+ dc;
}
if(dc.length == 0) {
var yourname = prompt('Do enter your name for a proper welcome :', '');
if (yourname == '' || yourname == 'null') {yourname = 'mex';}
else {yourname = yourname;}
document.getElementById('welcome').innerHTML = 'Welcome '+ yourname;
var today = new Date();
today.setTime(today.getTime() + 1*60*60*1000);
var expString = "; expires=" + today.toGMTString();
document.cookie = yourname + expString;
}
}
window.onload = doWelcome;
//-->
</script>
</HEAD>
<BODY>
<span id="welcome"></span> </body></html>
<html><head><title>mex</title>
<script type="text/javascript">
<!--//
function doWelcome() {
var dc = document.cookie;
if(dc.length > 0) {
document.getElementById('welcome').innerHTML = 'Welcome back '+ dc;
}
if(dc.length == 0) {
var yourname = prompt('Do enter your name for a proper welcome :', '');
if (yourname == '' || yourname == 'null') {yourname = 'mex';}
else {yourname = yourname;}
document.getElementById('welcome').innerHTML = 'Welcome '+ yourname;
var today = new Date();
today.setTime(today.getTime() + 1*60*60*1000);
var expString = "; expires=" + today.toGMTString();
document.cookie = yourname + expString;
}
}
window.onload = doWelcome;
//-->
</script>
</HEAD>
<BODY>
<span id="welcome"></span> </body></html>
Comment