Categories
How To Article

HTML noscript tag

On my latest assignment, I followed up with the confusion as to what to do in case of web browsers which does not support AJAX or eventually Javascript.

Before following up with the tutorial it is important for all of us to understand that AJAX brings with it a loads of responsibility to a developer, before posing its nose in security threats and bars coined in the application. As using AJAX is not a mandatory choice nevertheless it brings with it a lot of good features which would have been very difficult to handle with conventional Request/Response cycle (Synchronous in nature).

But what in case if our web page has some Javascript code to run in the background and our browser settings are not feasible to run it successfully or not running it at all. Showing a blank page, does not make it a good choice, as heavy applications might fail on the note of adaptability and hence user will end up on either seeking Customer support or else google for alternatives.

The answer to our concern is, the NOSCRIPT tag provided by HTML which can be used to provide some logical error messages or else can be directed to an Error page listing appropriate errors, and hence informing the user to enable his browser settings.

A JSP example to help understand whatever is described above is as follows:

<%–
Document   : index
Created on : Feb 6, 2013, 3:03:34 PM
Author     : hvashistha
–%>

<%@page contentType=”text/html” pageEncoding=”UTF-8″%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8″>
<title>JSP Page</title>

<script>
function checkCompatible() {
document.write(“Can we write Javascript code here ?”);
}
</script>

</head>
<body onload=”checkCompatible()”>
<noscript>
<h1>Error Listing Page!</h1>
<ul>
<li>Your browser is not Javascript compatible.Please ensure your browser settings are good enough to run Javascript code</li>
</ul>
</noscript>
</body>
</html>

Description:

The above example calls a javascript function checkCompatible onload of its body. If your browser settings are such, so that it can support Javascript code then something like this will come up on your browser:

Javascript_Allowed

Otherwise,

Javascript_Not_Allowed

So, the next time you start developing a web application with AJAX and Javascript support make sure you are equipped with this knowledge, so as to ease out User.

Lets make web a User-friendly place with a smile.