嘗試用下面的代碼,使用navigator
對象::
var ua = navigator.userAgent;
if(navigator.appName == "Netscape"){ //for Firefox, Safari and Chrome
//do nothing, stay on this page.
return;
}
else if(navigator.appName == 'Microsoft Internet Explorer'){
//check for version
var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
if (re.exec(ua) != null){
version = parseFloat(RegExp.$1);
}
if(version >= 9.0){
//do nothing, stay on this page.
return;
}
else{
//redirect to the site for lower IE versions.
}
}
else if(ua.match(/Android/i)){
//code for skipping to Android version
}
else if(ua.match(/iPhone/i)){
//code for skipping to iPhone version
}
else if(ua.match(/iPad/i)){
//code for skipping to iPad version
}
乾杯爲你的幫助Sohel - 雖然我已經添加了上述每種情況的警報,並且Iphone/Ipad/Android警報作爲第一個netscape選項 – Dancer
我將iphone/ipad/android的if語句嵌套到netscape if語句中,並且它工作得很好!歡呼你的幫助! – Dancer