下面的例子检测当前窗口是否在一个框架中,如果是则跳出框架:
<html>
<head>
<script type="text/javascript">
function breakout(){
if (window.top!=window.self){
window.top.location="http://www.520mg.com"
}
}
</script>
</head>
<body>
<button onclick="breakout()">跳出框架</button>
</body>
</html>