Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 根据用户的位置而不是浏览器语言重定向用户_Javascript_Jquery_Html_Redirect - Fatal编程技术网

Javascript 根据用户的位置而不是浏览器语言重定向用户

Javascript 根据用户的位置而不是浏览器语言重定向用户,javascript,jquery,html,redirect,Javascript,Jquery,Html,Redirect,我正在为一家公司做一个网站。我有三种语言:英语、挪威语和冰岛语。我发现了通过浏览器语言重定向用户的Java脚本。有没有办法根据用户的位置进行重定向?比如在mtv.com网站上。谢谢大家! 抓住这个库 您甚至可以使用带/不带jQuery您可以使用地理定位,就像使用不需要jQuery一样 下面是一个您可以做的示例: <script language="Javascript" src="http://gd.geobytes.com/gd?after=-1&variables=Geobyt

我正在为一家公司做一个网站。我有三种语言:英语、挪威语和冰岛语。我发现了通过浏览器语言重定向用户的Java脚本。有没有办法根据用户的位置进行重定向?比如在mtv.com网站上。谢谢大家!

抓住这个库


您甚至可以使用带/不带jQuery

您可以使用地理定位,就像使用不需要jQuery一样

下面是一个您可以做的示例:

<script language="Javascript" src="http://gd.geobytes.com/gd?after=-1&variables=GeobytesLocationCode,GeobytesCode,GeobytesInternet"></script>
<script language="Javascript">
if(typeof(sGeobytesLocationCode)=="undefined"
   ||typeof(sGeobytesCode)=="undefined"
   ||typeof(sGeobytesInternet)=="undefined")
{
   // Something has gone wrong with the variables, so set them to some default value,
   // maybe set a error flag to check for later on.
   var sGeobytesLocationCode="unknown";
   var sGeobytesCode="unknown";
   var sGeobytesInternet="unknown";
}
if(sGeobytesLocationCode=="CAQCMONT")
{
   // Visitors from Montreal would go here
   window.open("enter Montreal URL here");
}else if(sGeobytesCode=="QC")
{
   // Visitors from Quebec would go here
   window.open("enter Quebec URL here");
}else if(sGeobytesInternet=="CA")
{
   // Visitors from Canada would go here
   window.open("enter Canada URL here");
}
</script>

我也可以在你的帮助下向你求婚。它可以让你获得很多关于用户本地化的信息,比如is国家。在满足某些条件后,您可以将用户重定向到正确的页面。

这通常不是一个好主意。仅仅因为一个旅行者可能在某个国家,并不意味着他想要用那种语言提供服务。这是一家标志制作公司,所以它更像是企业对企业。我认为这对这个项目会有好处。你认为哪一个更好?我明白,与谷歌可能会有一些冲突。现在我将有3.html文件,但客户端将有3个不同的域。所以我想,如果挪威的客户将访问.com域名重定向到.no网站。谢谢你的回复。我已经看到了这个选项,但我不喜欢他们每50个重定向中就有一个弹出广告。