嗨,如果我的主主机出现故障,我有书签代码可以从镜像备份位置加载脚本,它可以工作,但我想知道最好的方法,因为我知道我目前的做法可能不是最好的方法.
(这是我的备用书签代码扩展的示例)
javascript: (function () {
var scriptname = 'testscript';
function checkServerStatus() {
var v = setTimeout(function () {
loadscript('backupserver.hardiman.co.nz')
}, 4500);
var a = document.body.appendChild(document.createElement('img'));
a.onload = function () {
clearTimeout(v);
loadscript('screepts.com')
};
a.src = 'http://screepts.com/ping.gif?' + Math.random();
}
checkServerStatus();
function loadscript(b) {
var a = document.createElement('script');
a.type = 'text/javascript';
a.src = 'http://' + b + '/bm/' + scriptname + '.js?' + Math.random();
document.getElementsByTagName('head')[0].appendChild(a)
}
})();`
这是一个小书签:
<a href="javascript:%28function%28%29%7Bvar c%3D'testscript'%3Bfunction checkServerStatus%28%29%7Bvar v%3DsetTimeout%28function%28%29%7Bloadscript%28'backupserver.hardiman.co.nz'%29%7D,4500%29%3Bvar a%3Ddocument.body.appendChild%28document.createElement%28'img'%29%29%3Ba.onload%3Dfunction%28%29%7BclearTimeout%28v%29%3Bloadscript%28'screepts.com'%29%7D%3Ba.src%3D'http://screepts.com/ping.gif%3F'%2BMath.random%28%29%3B%7DcheckServerStatus%28%29%3Bfunction loadscript%28b%29%7Bvar a%3Ddocument.createElement%28'script'%29%3Ba.type%3D'text/javascript'%3Ba.src%3D'http://'%2Bb%2B'/bm/'%2Bc%2B'.js%3F'%2BMath.random%28%29%3Bdocument.getElementsByTagName%28'head'%29%5B0%5D.appendChild%28a%29%7D%7D%29%28%29%3B">Test Script</a>
任何有关从备份服务器加载脚本的帮助或建议将不胜感激。
好的,对不起,我应该更具体地讨论这个问题。由于我的主机出现故障,我能够正确测试上述代码。我认为我唯一需要做的就是解析加载到脚本的服务器。