Prevent your own web page from being framed by people
Top.location.href the top of the address
Windows.location.href own address.
Self refers to the current Window object, which belongs to the topmost object of Windows;
Location.href refers to the URL address of a Window object.
Self.location.href refers to the URL address of the current window, removing the URL of the current window that the self defaults
| The code is as follows |
Copy Code |
<script type= "Text/javascript" > if (top.location!= self.location) { Top.location = self.location;//prevents the page from being contained by the frame } </script>
|
1. These methods are feasible, but not too reliable.
| code is as follows |
copy code |
| <script language= "JavaScript" if (top.location!= self.location) top.location.href=self.location.href; </ Script> or <script language= "JavaScript" if (top.location!= location) Top.location.href = Location.href; </script> or <script language= "JavaScript" if (top.location!= self.location) {top.location=self.location;} </script> or <script language= "JavaScript" if (top.frames.length!=0) top.location=self.document.location; </script> |