How to automatically redirect the browser to another page
Redirecting like this can be done either using JavaScript or with an “HTTP-EQUIV Refresh” meta tag. Both of these approaches are covered below.
Redirecting with JavaScript
The following is the complete HTML for an example of redirecting using JavaScript:
<html>
<body>
<p align="center">The page you are looking for is not here. Try:</p>
<p align="center">
<a href= "http://www.cryer.co.uk/resources/htmljavascript.htm">
www.cryer.co.uk/resources/htmljavascript.htm</a></p>
<p align="center">If you are not redirected automatically within a few
seconds then please click on the link above.</p>
<script type="text/javascript"><!--
setTimeout('Redirect()',4000);
function Redirect()
{
location.href = '../htmljavascript.htm';
}
// --></script>
</body>
</html>
Redirecting with HTTP-EQUIV Refresh
The “Refresh” http-equiv meta-tag allows you to specify a timeout and a new page to load once that timeout has expired. To use it add the following to the HTML of the page line between the<head> and </head> tags:
<meta http-equiv="refresh" content="5; url=http://www.devguru.in">
Note:
- The timeout (shown here as 5) is in seconds.
- Be sure to change the URL to that of the desired page.
- Insert double quotes exactly as shown.
<html> <head> <meta http-equiv="refresh" content="4; url=http://www.devguru.in/resources/htmljavascript.htm"> </head> <body> <p align="center">The page you are looking for is not here. Try:</p> <p align="center"> <a href="http://www.devguru.in/resources/htmljavascript.htm"> www.devguru.in/resources/htmljavascript.htm</a></p> <p align="center">If you are not redirected automatically within a few seconds then please click on the link above.</p> </body> </html>
Other Considerations
Which style of redirect you choose to use is up to you. There is no reason why these two approaches could not both be used on the same page. This would have the advantage that whilst some browsers might have JavaScript disabled and others might not respond to the HTTP-EQUIV tag, it is most likely that one or the other approach will be successful.
If you use this technique because you have moved a page then it is probably wise to leave a message to search engines that they should no longer index the page. The easiest way of doing this is to use the following meta tag:
<meta name="robots" content="noindex">
Which should be included between the opening <HEAD> and closing </HEAD> tags in the HTML, for example:
<html> <head> <meta name="robots" content="noindex"> </head>
Hyper link Table Tr Using JavaScript
<script type="text/javascript">
function mouseOver(rowID,strClass,type)
{
//alert(rowID + ' | ' + strClass + ' | ' + type);
if (type == 1)
{
document.getElementById('right' + rowID).className= strClass;
}
else if (type == 2)
{
document.getElementById('left' + rowID).className= strClass;
}
}
function mouseOut(rowID,strClass,type)
{
//alert(rowID + ' | ' + strClass + ' | ' + type);
if (type == 1)
{
document.getElementById('right' + rowID).className= strClass;
}
else if (type == 2)
{
document.getElementById('left' + rowID).className= strClass;
}
}
</script>
<%
int rowID = 0;
while (resultSet.next())
{
------
-------
rowID += 1;
%>
<tr>
<td> </td>
<td>
<a href="#" class="link" id="left<%=rowID%>" onmouseover="mouseOver(<%=rowID%>,'link2',1)" onmouseout="mouseOut(<%=rowID%>,'link',1)">Left link</a>
</td>
<td> </td>
<td>
<a href="#" class="link" id="right<%=rowID%>" onmouseover="mouseOver(<%=rowID%>,'link2',2)" onmouseout="mouseOut(<%=rowID%>,'link',2)">Right link</a>
</td>
</tr>
<%
}
%>
This Post is shared by Aldrin Pereira @ aldrin.pereira@gmail.com
