2
   

Meta refresh, how to make a page redirect to another page

 
 
Reply Wed 15 Jan, 2003 11:23 am
This tag will redirect your visitor to another page. Place it between the head tags of your page.

Quote:
<META HTTP-EQUIV="REFRESH" CONTENT="120;URL=http://www.able2know.com">


Change this to the time in seconds you'd like the page to delay the redirect.

Change this to the page you'd like to redirect to.

If you want the page to display a counter to the redirect use this example page:

Quote:
<html>

<head>
<META HTTP-EQUIV="REFRESH" CONTENT="120;URL=http://www.able2know.com.com">
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
startday = new Date();
clockStart = startday.getTime();
function initStopwatch() {
var myTime = new Date();
var timeNow = myTime.getTime();
var timeDiff = timeNow - clockStart;
this.diffSecs = timeDiff/1000;
return(this.diffSecs);
}
function getSecs() {
var mySecs = initStopwatch();
var mySecs1 = ""+mySecs;
mySecs1= mySecs1.substring(0,mySecs1.indexOf(".")) + " secs.";
document.form1.timespent.value = mySecs1
window.setTimeout('getSecs()',1000);
}
// End -->
</SCRIPT>
</head>
<BODY onLoad="window.setTimeout('getSecs()',1)">
<FORM NAME="form1">
<input type="text" value="" name="timespent" size=10>
</FORM>
</body>
</html>
  • Topic Stats
  • Top Replies
  • Link to this Topic
Type: Discussion • Score: 2 • Views: 23,448 • Replies: 10
No top replies

 
Craven de Kere
 
  1  
Reply Wed 22 Jan, 2003 10:00 pm
Note: there are many other redirect solutions. I'll supply them if they are needed by anyone.
0 Replies
 
Monger
 
  1  
Reply Mon 10 Mar, 2003 10:45 am
What about redirecting based on the visitor's country? What's the simplest way to do this? I'm trying to redirect everyone visiting my site from Japan to a different page, but so far I haven't been able to get this one SmartRedirector 1.3 working.
0 Replies
 
Craven de Kere
 
  1  
Reply Mon 10 Mar, 2003 02:23 pm
I have some bad news. Redirecting based on country would require IP redirection and IP redirection isn't a matter of simple code but one involving both code and an IP database. And such redirections will wreak havok on most SEO systems, you might even get blacklisted from some search Engines if you don't do it right.

The script you linked to did not correctly identify my location by IP and I did not use any proxies while running the test. And IP redirection is inherently problematic. German visitors using AOL will sometimes look like they are browsing from the US.

There are solutions to this but I do not know of any good ones that are free. A free example would be to use a whois request every time but you'll be banned from using whois because of the volume of requests.

You have already tested http://www.mimtech.com/download/SmartRedirector.zip
and after a quick look I can only say that it didn't work for me in php or perl.

http://sourceforge.net/projects/gnation/ <, this is an open source project related to this


If you want an easy way this is your best bet:
http://www.geobutton.com/geophrase.htm
Quote:
Register for our advanced service, which is also FREE and create your own templates. You can use our advanced service to create your own phrases, paragraphs and even whole pages based on the geographical location of your site's visitors. As we said, the advanced service is still FREE, but you will need to register to use it. We need you to register so that our system can recognize you and allow you to modify your template in the future. This also protects your template, by allowing us to restrict access to your template to only yourself.




What I'd do is create a first visit only splash page that gives the choice of countries and then forever redirects based upon that cookie, or if you don't want cookies you can make it database driven (assuming you will use registration).

Another option is to make it redirect based on languages. I have never done that but am pretty sure it can be done. This is also called language based cloaking.

Here is a list of language abbreviations.
I will add code for such redirection there.



But if you really want to go the IP route and are willing to pay here ya go:

http://www.georedirect.com/

http://www.geobytes.com/ You can test their accuracy here: http://www.networldmap.com/TryIt.htm

http://www.maxmind.com/ << this has a free database option but they also charge for a better one.

http://www.location.com.my/

Or if you want to maintain your own IP directory here are some lists:

http://www.ripe.net/ripencc/mem-services/general/allocs.html

http://ftp.apnic.net/pub/stats/apnic/ (Asia)
ftp://ftp.arin.net/pub/stats/arin/ (America)
ftp://ftp.ripe.net/ripe/stats/ (Europe)

Here are links for reference:

http://www.zooknic.com/Analysis/index.html
0 Replies
 
Craven de Kere
 
  1  
Reply Mon 10 Mar, 2003 11:06 pm
Try this monger:

Code:<?php
if (stristr($HTTP_ACCEPT_LANGUAGE, 'ja')) {
Header('Location:japan.html');
} else Header('Location:index.html');


?>


Save it to a file with a php extension ( e.g. anyname.php).
0 Replies
 
Monger
 
  1  
Reply Tue 11 Mar, 2003 02:20 am
Cool, Craven! That's a great resourse for redirection you've put together there. The PHP language-based option you wrote there would probably be a good solution for most, however I'm only targetting the foreign community in Japan so that doesn't exactly work out for me. Smile Cookies seems like a cool idea too, and I might try to do that in the future, however I think I'll just go with the free geophrase one you listed for now. Thanks, dude. :wink:
0 Replies
 
may2521
 
  1  
Reply Tue 29 Jul, 2003 02:38 pm
How do I test if this work?
Could you please tell me how to test this <META HTTP-EQUIV="Reload" ...>? I tried running my page with the tag to reload a new page and it doesn't go anywhere. Then I tried with Apache server running, it did nother either. Any suggestion will be greatly appreciated.

May Shocked
0 Replies
 
Craven de Kere
 
  1  
Reply Tue 29 Jul, 2003 02:44 pm
Reload? or Refresh?

That's probably your error. It needs to be "Refresh".
0 Replies
 
StuartC
 
  1  
Reply Fri 8 Jun, 2007 07:02 am
auto page redirect based on user choice from a splash screen
Hi All,

Sorry for my first post being a question rather than just a hi! So hi first Wink

Hopefully this old post will be bumped by my reply, so here goes...

I am trying to complete a task for work where they would like users to be automatically redirected to a specific country's page based on an option they select from a splash screen every time they go to that page.

Unfortunately the company I work for still lives pretty much in the dark ages so this would have to be a javascript / cookie / html solution. I did a quick google for meta refreshing to a specific page based on a cookie and didnt find anything atall apart from this post which looks very promising.

Craven suggested in one of his posts that this was very possible, but I could not see a link to an example of this being done, or the code used. If possible would someone be able to explain to me what needs to be done to make this word and give an example of where it is being done.

There are only 2 options on this splash screen which are choices between viewing the content of a site in 2 different languages both of which have separate URLs and so a meta refresh should work fine here as no variable needs to be taken through to define the users language selection.

I think thats everything, any help is greatly appreciated.
0 Replies
 
Craven de Kere
 
  1  
Reply Sun 10 Jun, 2007 08:56 am
Here is an example that does all that you describe. Just change as needed. Note that it may not work from a local file on your computer and if so upload to a server for testing.

Code:
<html>
<head>
<script>
var expDays = 30;
var exp = new Date();
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));

function getCookieVal (offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return getCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
function SetCookie (name, value) {
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
document.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}
function DeleteCookie (name) {
var exp = new Date();
exp.setTime (exp.getTime() - 1);
var cval = GetCookie (name);
document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}

var favorite = GetCookie('animal');

if (favorite != null) {
switch (favorite) {
case 'cat' : url = 'cat.html'; // change these!
break;
case 'dog' : url = 'dog.html';
break;
case 'gerbil' : url = 'gerbil.html';
break;
case 'gopher' : url = 'gopher.html';
break;
}
// window.location.href = url;
alert('You would have been taken to the ' + favorite + ' page (' + url + '), but this is just a demo!');
}
</script>
</head>
<body>
<form>
<table><tr><td>
Please choose your Favorite Pet:<br>
<input type=checkbox name="cat" onClick="SetCookie('animal', this.name, exp);">Cat<br>
<input type=checkbox name="dog" onClick="SetCookie('animal', this.name, exp);">Dog<br>
<input type=checkbox name="gerbil" onClick="SetCookie('animal', this.name, exp);">Gerbil<br>
<input type=checkbox name="gopher" onClick="SetCookie('animal', this.name, exp);">Gopher<br>
</td></tr>
</table>
</form>
</body>
</html>
0 Replies
 
StuartC
 
  1  
Reply Mon 11 Jun, 2007 02:49 am
Thanks
Hi Craven,

Thanks for this! I will give it a go and let you know how I get on.

Stu
0 Replies
 
 

Related Topics

In How much time a website can be developed? - Question by aussiejumpingcastle
Webdevelopment and hosting - Question by harisit2005
Showing an Ico File - Discussion by Brandon9000
how to earn money in internet - Discussion by rizwanaraj
The version 10 bug. Worse then Y2K! - Discussion by Nick Ashley
CSS Border style colors - Question by meesa
There is no Wisdom in Crowds - Discussion by ebrown p
THANK YOU CRAVEN AND NICK!!! - Discussion by dagmaraka
I'm the developer - Discussion by Nick Ashley
 
  1. Forums
  2. » Meta refresh, how to make a page redirect to another page
Copyright © 2021 MadLab, LLC :: Terms of Service :: Privacy Policy :: Page generated in 0.03 seconds on 06/13/2021 at 05:39:41