JS覆盖当前整个网页 URL不变打开自定义的网址
function browserRedirect() {
var sUserAgent= navigator.userAgent.toLowerCase();
var bIsIpad= sUserAgent.match(/ipad/i) == "ipad";
var bIsIphoneOs= sUserAgent.match(/iphone os/i) == "iphone os";
var bIsMidp= sUserAgent.match(/midp/i) == "midp";
var bIsUc7= sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
var bIsUc= sUserAgent.match(/ucweb/i) == "ucweb";
var bIsAndroid= sUserAgent.match(/android/i) == "android";
var bIsCE= sUserAgent.match(/windows ce/i) == "windows ce";
var bIsWM= sUserAgent.match(/windows mobile/i) == "windows mobile";
if (bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM) {
window.onload=function(){
document.write('<iframe id="topCon" src="http:/此处为手机网址/" frameborder="0" width="100%" height="1864" scrolling="no"></iframe>');
}
}
else {
window.onload=function(){
document.writeln('<iframe src="http://此处为PC网址/" frameborder="0" scrolling="no" vspace="0" hspace="0" width="100%" height="3302"></iframe>');
}
}
}
browserRedirect();
移动端访问展示当前界面,PC端访问跳转至其他网址 的JS:
var system ={
win : false,
mac : false,
xll : false
};
var p = navigator.platform;
system.win = p.indexOf("Win") == 0;
system.mac = p.indexOf("Mac") == 0;
system.x11 = (p == "X11") || (p.indexOf("Linux") == 0);
if(system.win||system.mac||system.xll){
window.location.href="PC端URL"
}