Categories :- Asp.net java script validation for grid view in edit mode
Introduction :-
Open the new page after some time interval using asp.net
More Details :-
In my previous article i have provide the java script remove duplicate values from array and java script get user IP address.
In this article i have show how i can redirect to asp.net or any html page after some interval without click of any user.This type of functionality e use in html5 game for show the instruction and after display the instruction page automatically redirect to game play screen.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="interval.aspx.cs" Inherits="interval" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Java scripts Interval and redirect to other page</title>
<script type="text/javascript">
var i = 0;
function ShowCurrentTime() {
var dt = new Date();
document.getElementById("lblTime").innerHTML = 5 - i + " Seconds";
i++;
if (i == 5) {
setTimeout("location.href='http://dotnethubs.blogspot.in'", 0);
}
window.setTimeout("ShowCurrentTime()", 1000); // 1000 equal to 1 sec
}
</script>
</head>
<body onload="ShowCurrentTime()">
<form id="form1" runat="server">
<div>
<label id="lblTime" style=" font-weight:bold; font-size:x-large"></label>
</div>
</form>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Java scripts Interval and redirect to other page</title>
<script type="text/javascript">
var i = 0;
function ShowCurrentTime() {
var dt = new Date();
document.getElementById("lblTime").innerHTML = 5 - i + " Seconds";
i++;
if (i == 5) {
setTimeout("location.href='http://dotnethubs.blogspot.in'", 0);
}
window.setTimeout("ShowCurrentTime()", 1000); // 1000 equal to 1 sec
}
</script>
</head>
<body onload="ShowCurrentTime()">
<form id="form1" runat="server">
<div>
<label id="lblTime" style=" font-weight:bold; font-size:x-large"></label>
</div>
</form>
</body>
</html>
Download sample code attached
No comments:
Post a Comment