Redirect to referrer page using only the meta tag

July 27th, 2009 in Web UI Programming. Add comment
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

While there may be several ways to return to the referring url using javascript, php etc, the same effect can be achieved using the ‘meta’ tag and Server Side Includes. Useful if you do not know javascript or php.

The following meta tag is commonly used to refresh/redirect a page to the same or another URL after a given number of seconds:

<META HTTP-EQUIV=”Refresh” CONTENT=’3; URL=http://www.someURL.com’ >

This can be modified to redirect to the referring page in 3 seconds using HTTP_REFERRER. The following is an html snippet that demonstrates this.

<html>
<head>
<META HTTP-EQUIV="Refresh" CONTENT='3; URL=<!--#echo var="HTTP_REFERER" -->'>
</head>
<body>
 blah
</body>
</html>

Of course, your webserver will need to support Server Side Includes for this to work. That means if you are using apache, check if you have the following in your httpd.conf

Options Includes
AddHandler server-parsed .html .shtml
AddType text/html .html .shtml

Related Posts:

Create a table with a 1 pixel border in html/css

File upload without page refresh.

Tags:

Leave a Reply

Sponsors