點擊跳轉(zhuǎn)外部鏈接,提示你已離開本站,跳轉(zhuǎn)的頁面與本站無關(guān)的實現(xiàn)代碼,很多政府網(wǎng)站都會用到。代碼如下:
建立一個jump.html
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>頁面跳轉(zhuǎn)中...</title>
</head>
<body>
<div><b>您已離開湛江市安全生產(chǎn)監(jiān)督管理局門戶網(wǎng)站,接下來跳轉(zhuǎn)至的頁面與本站無關(guān)。</b><br />
頁面跳轉(zhuǎn)中...</div>
<script>
function kb1(str) {
return str.replace(/<(script|link|style|iframe)(.|\n)*\/\1>\s*/ig, "");
}
function kb2(str) {
return str.replace(/<[a-z][^>]*\s*on[a-z]+\s*=[^>]+/ig,
function($0, $1) {
return $0.replace(/\s*on[a-z]+\s*=\s*("[^"]+"|'[^']+'|[^\s]+)\s*/ig, "");
});
}
function kb3(str) {
return str.replace(/<[a-z][^>]*\s*(href|src)\s*=[^>]+/ig,
function($0, $1) {
$0 = $0.replace(/&#(6[5-9]|[78][0-9]|9[0789]|1[01][0-9]|12[012]);?/g,
function($0, $1) {
return String.fromCharCode($1);
});
return $0.replace(/\s*(href|src)\s*=\s*("\s*(javascript|vbscript):[^"]+"|'\s*(javascript|vbscript):[^']+'|(javascript|vbscript):[^\s]+)/ig, "");
});
}
function kb4(str) {
return str.replace(/<[a-z][^>]*\s*style\s*=[^>]+/ig,
function($0, $1) {
$0 = $0.replace(/&#(6[5-9]|[78][0-9]|9[0789]|1[01][0-9]|12[012]);?/g,
function($0, $1) {
return String.fromCharCode($1);
});
return $0.replace(/\s*style\s*=\s*("[^"]+(expression)[^"]+"|'[^']+\2[^']+'|[^\s]+\2[^\s]+)\s*/ig, "");
});
}
var hrefstr = window.location.href;
var args = hrefstr.split("?")[1];
var url = kb1(kb2(kb3(kb4(args))));
var strlength, urlto;
if (url != "url=http://www.jiemi88.cn/jump.htm") {
if (url.substring(0, 11).toLowerCase() == "url=http://") {
strlength = url.length;
urlto = url.substring(4, strlength);
setTimeout(function() {
window.location = urlto;
},
3000);
}
}
</script>
</body>
</html>
比如,想跳轉(zhuǎn)到www.baidu.com,只需訪問:
jump.htm?url=http://www.baidu.com 這個就可以了