/**
*
* @param {引入的代码判断} pageName
*/
function uploadPage(pageName) {
/*根据不同的客户端(这里指移动端和pc端)引入样式*/
var includeLinkStyle = function (url) {
var link = document.createElement('link');
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = url;
document.getElementsByTagName('head')[0].appendChild(link);
};
function browserRedirect(pageName) {
/* 判断是pc端还是移动端 网上有很多,我只用其中一种演示*/
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) {
includeLinkStyle("./css/mobile.css");
$('body').load(pageName);
} else {
includeLinkStyle("./css/pc.css");
$('body').load(pageName);
}
};
browserRedirect(pageName);
}
打开App,阅读手记