6 Agu 2011

No iframe my page !

berikut adalah cara untuk menghindari halaman kita di iframe oleh orang lain…
seperti yang digunakan oleh twitter

<code>
01<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
02
03<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
04<head><title>test. no iframe-ing this page</test> </head>
05
06<body bgcolor="blue">
07
08<script type="text/javascript">
09//<![CDATA[
10if (window.top !== window.self) {
11        document.write = "";window.top.location = window.self.location;
12        setTimeout(function(){document.body.innerHTML='';},1);
13        window.self.onload=function(evt){document.body.innerHTML='';};
14        }
15//]]>
16</script>
17
18<h1>this is BLUE<br> <? echo $_SERVER["PHP_SELF"] ?> </H1>
19
20</body>
21</html>
</code>

./vM




Detected

Your Browser's JavaScript is: