当我尝试动态选择的样式不加载时,我试图想出一种默认为标准样式的方法。例如,如果ORG_ID与有效文件无关,我会尝试404访问它。
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0" />
<title>WhiteLabel</title>
<link rel="shortcut icon" href="images/favicon.png" />
<link rel="apple-touch-icon" href="images/apple-touch-icon.png" />
<script>
try {
var ORG_ID = window.location.search.match(/org_id=([0-9]+)/)[1];
} catch (e) {
console.log("Error encounterd: " + e);
document.write("<link rel='stylesheet' href='js/jquery.mobile-1.2.0/jquery.mobile-1.2.0.min.css'>");
}
if (ORG_ID[1]) {
document.write("<link rel='stylesheet' href='themes/" + ORG_ID + ".min.css'>");
document.write("<link rel='stylesheet' href='js/jquery.mobile-1.2.0/jquery.mobile.structure-1.2.0.min.css'>");
} else {
document.write("<link rel='stylesheet' href='js/jquery.mobile-1.2.0/jquery.mobile-1.2.0.min.css'>");
}
</script>
</head>