Friday, June 15, 2007

Showing an alert using Javascript

This is the Javascript code to show an alert if users keep the web page open & unattended for more than 10 minutes.

----------------------------------------------------------------------------------------------------------------------------------

<BODY onload="pageload();">

----------------------------------------------------------------------------------------------------------------------------------

function pageload()

{

window.setInterval("SetAlert()",480000);

}

----------------------------------------------------------------------------------------------------------------------------------

function SetAlert()

{

//In my example alert is on the same page. You can embed another .html page also here.

document.getElementById('divSession').style.display='';

document.getElementById('divSession').style.posTop=200;

document.getElementById('divSession').style.posLeft=250;

document.getElementById('divSession').style.width=430;

document.getElementById('divSession').style.height=130;

window.setInterval("document.getElementById('divSession').style.display='none'",115000);

}

----------------------------------------------------------------------------------------------------------------------------------

<div id="divSession" runat="server" style="DISPLAY: none; Z-INDEX: 101; BORDER-LEFT-COLOR: whitesmoke; LEFT: 600px; BORDER-BOTTOM-COLOR: whitesmoke; WIDTH: 248px; BORDER-TOP-STYLE: ridge; BORDER-TOP-COLOR: whitesmoke; FONT-FAMILY: 'Times New Roman'; BORDER-RIGHT-STYLE: ridge; BORDER-LEFT-STYLE: ridge; POSITION: absolute; TOP: 25px; HEIGHT: 198px; BACKGROUND-COLOR: lightgrey; BORDER-RIGHT-COLOR: whitesmoke; BORDER-BOTTOM-STYLE: ridge">

<table border="0" cellpadding="0" cellspacing="0">

<tr>

<td valign="middle">

<p align="center"><br>

You are not browing this site from 10 minutes. <!--Anything can go here-->

 <br>

<INPUT type='submit' value='OK' onClick='CloseWin()' style="WIDTH: 103px" ID="Submit1"

NAME="Submit1">

</p>

</td>

</tr>

</table>

</div>

----------------------------------------------------------------------------------------------------------------------------------

function CloseWin()

{

 //Anything you can write here.

document.getElementById('divSession').style.display='none';

}

1 comment:

Anonymous said...

Don’t write your comments again