<html>
<head>
<meta charset="gbk">
<title>我做的很棒的弹出内容!</title>
<script>
function xssCheck(str,reg){
return str ? str.replace(reg ||/[&<">'](?:(amp|lt|quot|gt|#39|nbsp|#\d+);)?/g,function (a, b) {
if(b){
return a;
}else{
return{
'<':'<',
'&':'&',
'"':'"',
'>':'>',
"'":''',
}[a]
}
}): '';
}
function awesome() {
// 做些很棒的事情!
alert(xssCheck(''));
}
function clickHandler(element) {
setTimeout("awesome();", 100);
}
</script>
</head>
<body>
<button onclick="clickHandler(this)">
单击看看会发生什么!
</button>
</body>
</html>