Anti Iframe Buster by Lex Johnson
Abstract
Like using iframes on your site but worried about people using javascript to bust out of them? Use this code to bust the busters!
Description
iframes are a necessary evil for many of us. Putting a third party site in an iframe is always a risk because they can break out of that iframe and redirect the visitor. This code acts as a defense and prevents them from being able to bust out of the iframe.
Code Snippet
<script type="text/javascript">
var prevent_bust = 0
window.onbeforeunload = function() { prevent_bust++ }
setInterval(function() {
if (prevent_bust > 0) {
prevent_bust -= 2
window.top.location = 'http://server-which-responds-with-204.com'
}
}, 1)
</script>


Leave a Response
(0 comments)