Search content within the blog

Wednesday, December 24, 2008

Checking if javascript is disabled in the browser

in your head section of the html page you will have some script written as folows,

<script type="text/javascript">
//just add the below line
document.write("");

function somefunction()
{
//
}
</script>

and before closing of the head tag add the following lines
<NOSCRIPT>
<meta http-equiv="REFRESH" content="0;URL=JavascriptDisabled.aspx"/> </NOSCRIPT>
here JavascriptDisabled.aspx is the page where the user will be redirected if the javascript is disabled

contents for JavascriptDisabled.aspx can be as follows
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="JavascriptDisabled.aspx.cs" Inherits="JavascriptDisabled" %>

<!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>Loobalee-Javascript Disabled</title>
</head>
<body bgcolor="Lightblue">
<form id="form1" runat="server">
<div>
<table style="top:750px" align="center" width="50%" border="1">
<tr>
<td style="color:White">
Javascript is disabled in your browser .Enable javascript and try re-loading the page else <a href="Visitor/Login.aspx">Click Here</a>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>

No comments:

Post a Comment