点击跳转外部链接,提示你已离开本站,跳转的页面与本站无关的实现代码,很多政府网站都会用到。代码如下:
建立一个jump.html
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>页面跳转中...</title>
</head>
<body>
<div><b>您已离开湛江市安全生产监督管理局门户网站,接下来跳转至的页面与本站无关。</b><br />
页面跳转中...</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.01jianzhan.com/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>
比如,想跳转到www.baidu.com,只需访问:
jump.htm?url=http://www.baidu.com 这个就可以了