If statement 不同语言的域切换器按钮

If statement 不同语言的域切换器按钮,if-statement,menu,If Statement,Menu,我想创建一个下拉菜单,在Javascript/jQuery中使用英语或德语作为选项,用于检查: check if on a domain - say happy.com/pizza if german is selected on dropdown redirect user to happy.de/pizza 我可以有一份清单 if happy.com/pizza got to happy.de/pizza happy.com/coke got to happy.de/coke

我想创建一个下拉菜单,在Javascript/jQuery中使用英语或德语作为选项,用于检查:

check if on a domain  - say happy.com/pizza 
if german is selected on dropdown 
redirect user to 
happy.de/pizza
我可以有一份清单

if happy.com/pizza got to happy.de/pizza  
happy.com/coke got to happy.de/coke  
happy.com/juice got to happy.de/juice
等等

我已经写了代码,但如何才能做到这一点呢

谢谢

我已经写了一些代码,但我只需要一点帮助,请:

在这个场景中,我在www.something.com/beer页面上,希望它转到德语啤酒页面

<select>
    <option value="1">English</option>
    <option value="2">German</option>
</select>


if(value == 2)  && is current domain www.something.com/beer{
    window.top.location.href = 'www.something.de/beer'; 
}else if(value == 2)  && is current domain www.something.com/cheese{
    window.top.location.href = 'www.something.de/cheese'; 
}else{
    do nothing
}

英语
德国的
if(value==2)&&是当前域www.something.com/beer{
window.top.location.href='www.something.de/beer';
}如果(值==2)&&是当前域www.something.com/cheese{
window.top.location.href='www.something.de/cheese';
}否则{
无所事事
}
我如何让它检查下拉列表的值和域当前是否打开

这是我的名片

再次感谢

功能电流(arr){
function current(arr) {
  //  discuss at: http://phpjs.org/functions/current/
  // original by: Brett Zamir (http://brett-zamir.me)
  //        note: Uses global: php_js to store the array pointer
  //   example 1: transport = ['foot', 'bike', 'car', 'plane'];
  //   example 1: current(transport);
  //   returns 1: 'foot'

  this.php_js = this.php_js || {};
  this.php_js.pointers = this.php_js.pointers || [];
  var indexOf = function (value) {
    for (var i = 0, length = this.length; i < length; i++) {
      if (this[i] === value) {
        return i;
      }
    }
    return -1;
  };
  // END REDUNDANT
  var pointers = this.php_js.pointers;
  if (!pointers.indexOf) {
    pointers.indexOf = indexOf;
  }
  if (pointers.indexOf(arr) === -1) {
    pointers.push(arr, 0);
  }
  var arrpos = pointers.indexOf(arr);
  var cursor = pointers[arrpos + 1];
  if (Object.prototype.toString.call(arr) === '[object Array]') {
    return arr[cursor] || false;
  }
  var ct = 0;
  for (var k in arr) {
    if (ct === cursor) {
      return arr[k];
    }
    ct++;
  }
  // Empty
  return false;
}
//讨论地点:http://phpjs.org/functions/current/ //原件:Brett Zamir(http://brett-zamir.me) //注意:使用global:php_js存储数组指针 //例1:运输=[‘脚’、‘自行车’、‘汽车’、‘飞机’]; //例1:当前(运输); //返回1:'英尺' this.php|u js=this.php|u js |{}; this.php_js.pointers=this.php_js.pointers | |[]; var indexOf=函数(值){ for(var i=0,length=this.length;i
考虑先编写一些代码,然后再分享,以指出实际问题。我现在正在这样做:)如果可能的话,只是想要一个指向正确方向的点?看一看:很抱歉,我不明白这一点!有人能帮我吗?