Question: How to redirect from a HTML page?

Ads

 
 
 

Share on Google+Share on Google+

Java Coder
How to redirect from a HTML page?
3 Answer(s)      3 years and 7 months ago
Posted in : HTML

Hi,

Is it possible to redirect from HTML page to another page on the net? I have one page and I want to redirect it to another page. What will be the code for redirecting the page to another page when use visits the first page.

Thanks

Ads
View Answers

October 8, 2013 at 10:35 PM


Yes, Its possible to redirect to another page using HTML code. You can use the following code:

<meta http-equiv="refresh" content="0; url=http://www.roseindia.net/">

The tag <meta http-equiv="refresh" />is used to refresh the browser after specified interval. Following code will refresh the page after 60 seconds:

<head>
<meta http-equiv="refresh" content="60">
</head>

This is one of the easiest way to refresh the page or redirect one page to another page.

Hope above code will help you.

View more tutorials at HTML tutorial index page.

Thanks



October 8, 2013 at 10:41 PM


Hi,

JavaScript can also be used to redirect the page to another page.

Here is the complete code example:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
    <HEAD>Example of HTML page redirect</TITLE>
        <script language="JavaScript">
        window.location.href = "http://www.roseindia.net"
        </script>
    </HEAD>

 <BODY>
  <P><a href='http://example.com'>Click here to visit another page</a></p>
 </BODY>
</HTML>

Here we are using window.location.href = "http://www.roseindia.net"for redirecting to another page.

When page loads JavaScript is executed and page is redirected to http://www.roseindia.net

Thanks



October 8, 2013 at 10:47 PM


Hi,

Another option is to use the HTTP 301 redirect. This solution is based on the Server Side solution of redirect. The Sever instruct the browser that the resource is permanently move to another url.

Client requests for the a resource on server:

GET /mypage.php HTTP/1.1
Host: www.roseindia.net

Server response:

HTTP/1.1 301 Moved Permanently
Location: http://www.roseindia.net/anotherresource.html

You can use the following code in your Servlet for this purpose:

response.sendRedirect("/ServletProject/ValidUser");

Here is an example of Send Redirect in Servlet.

Thanks


Ads









Related Tutorials/Questions & Answers:
Advertisements
Tutorials   
Java Spring Hibernate Struts Training How to display button as a link in vaadin? hi change navbar dropdown color in bootstrap How to remove the background color of bootstrap menu bar? How to change color of opened Bootstrap drop down toggle? Setting bootstrap container background color Help school all activities and admision process.. add one row after another date make a webpage HTMl HTMl Source code how to apply globalisation to a world wide asp.net application how to print HTML using javascript or Jquery How to recover from google panda update? How to survive google panda 4.0 update How to find if you have been hit by Panda 4.0 Design a web page using XHTML and JavaScript that does the followings: ffmpeg converting file mp4 to mov JavaScript How to Disable Catch-all Emails on CPanel z-index always on top What is Web hosting Database and HTML web development trainee Uploading files Image Gallery Image Gallery dropdown How to redirect from a HTML page? Easiest method for expiring the css and js headers HTML WITH AJAX VB 6 Read Web Page Header string palindrom using vbscript? html button How to add mod_deflate to apache without recompiling How to use place hoder in IE(version : 8) Html Software Question div align left css Fetching data from excel file on other website and display in interactive graph form where do I find the fix for tree view catalog not expanding and collapsing correctly for roseindia shopping cart 1.1 pass to next page to enter into a particular page only if the username,password and listbox value mtches hi Cricket stadium ticket booking design Need some help creating an order form. HTML div tag HTML div tag

Ads

 
Advertisement null

Ads