如果一個網站被加載到iframe中,我需要在該iFrame的子頁面上放置哪些代碼才能打開iFrame並將該頁面加載爲頂級文檔或將其重定向到該頁面使用javascript或jquery從iFrame重定向
剛剛發現的代碼
<script>
if(window.top !== window.self){
window.top.location.href = "http://www.blah.com";
}
</script>
更妙的是代碼:
<style> html{display : none ; } </style>
<script>
if(self == top) {
document.documentElement.style.display = 'block' ;
} else {
top.location = self.location ;
}
</script>
代碼下面的示例:
<!DOCTYPE html>
<html lang="en">
<head>
blah
</head>
<body>
<iframe src="www.blah.com"></iframe>
</body>
</html>
什麼JQuery或JavaScript我需要穿上(在這個例子中)www.blah.com所以它打破了iframe和www.blah.com直接顯示給用戶?
這會如何破壞iframe?這需要點擊iframe的子頁面上的鏈接。謝謝,但那不是我要找的 – Patriotec