Saturday, 4 April 2009

Avoid web page been embedded by others

The key is using window.top. The keyword 'top' is a property in window instance which returns you the very most top parent frame instance of current window. Code Sample:
   1:  <script type="text/javascript">
   2:  function a()
   3:  {
   4:      if (window != top)
   5:      {
   6:          top.location.href = window.location.href;
   7:      }
   8:  }
   9:   
  10:  window.onload = a;
  11:  </script>

No comments: