Javascript 是否将相同的值发送到另一个变量?
我必须形成页面,如果用户代理是移动的,我尝试将相同的值发送到另一个变量(linkmobile)。你能告诉我用最小编码的最好方法是什么吗Javascript 是否将相同的值发送到另一个变量?,javascript,jquery,Javascript,Jquery,我必须形成页面,如果用户代理是移动的,我尝试将相同的值发送到另一个变量(linkmobile)。你能告诉我用最小编码的最好方法是什么吗 var link = "reservation.html?"; var linkmobile = "reservation-mobile.html?"; link += "checkinYear="+ checkinYear; link += "&checkinDay="+ checkinDay; link += "&che
var link = "reservation.html?";
var linkmobile = "reservation-mobile.html?";
link += "checkinYear="+ checkinYear;
link += "&checkinDay="+ checkinDay;
link += "&checkinMonth="+ checkinMonth;
if(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|OperaMini/i.test(navigator.userAgent)) {
window.location.href = link-mobile;
}
else
window.location.href = link;
}
试试这个:
var link = "reservation.html?";
if(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|OperaMini/i.test(navigator.userAgent)) {
link = "reservation-mobile.html?";
}
link += "checkinYear="+ checkinYear;
link += "&checkinDay="+ checkinDay;
link += "&checkinMonth="+ checkinMonth;
window.location.href = link;
}
试试这个:
var link = "reservation.html?";
if(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|OperaMini/i.test(navigator.userAgent)) {
link = "reservation-mobile.html?";
}
link += "checkinYear="+ checkinYear;
link += "&checkinDay="+ checkinDay;
link += "&checkinMonth="+ checkinMonth;
window.location.href = link;
}
试试这个:
var link = "reservation.html?";
if(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|OperaMini/i.test(navigator.userAgent)) {
link = "reservation-mobile.html?";
}
link += "checkinYear="+ checkinYear;
link += "&checkinDay="+ checkinDay;
link += "&checkinMonth="+ checkinMonth;
window.location.href = link;
}
试试这个:
var link = "reservation.html?";
if(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|OperaMini/i.test(navigator.userAgent)) {
link = "reservation-mobile.html?";
}
link += "checkinYear="+ checkinYear;
link += "&checkinDay="+ checkinDay;
link += "&checkinMonth="+ checkinMonth;
window.location.href = link;
}
您的代码中有一个输入错误。您的变量首先被称为
linkmobile
,然后被称为linkmobile
。另外,您没有告诉我们您显示的代码中有什么不起作用。您的代码中有一个输入错误。您的变量首先被称为linkmobile
,然后被称为linkmobile
。另外,您没有告诉我们您显示的代码中有什么不起作用。您的代码中有一个输入错误。您的变量首先被称为linkmobile
,然后被称为linkmobile
。另外,您没有告诉我们您显示的代码中有什么不起作用。您的代码中有一个输入错误。您的变量首先被称为linkmobile
,然后被称为linkmobile
。另外,您没有告诉我们哪些代码不可用。