进来发现新闻源可以做得更好,那就是让新闻源页面直接跳转到自己想要的页面。当然,最好是这些新闻源价格不是很好,如果价格很好,就有点不是很划算了。废话不多说了,如何实现判断电脑pc还是移动手机客户端跳转到各自对应网址?
直接在新闻源的文章中加入一段js就好。源码如下:;
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.location.href="http://www.songzhiwei.com/";
}else{
window.location.href="http://3g.yidengyi.org/";
}
}
browserRedirect();