How to prevent iframe thieves?

How to prevent iframe thieves?

Hey,

This is what i found on internet:

  1. <script> 
  2.   if (self == top) {
  3.     var theBody = document.getElementsByTagName('body')[0]
  4.     theBody.style.display = "block"
  5.   } else { 
  6.     top.location = 'http://google.com' 
  7.   }
  8. </script>

I would like to get

if self url = mywebsite.com or mywebsite2.com
  show iframe
else block iframe
 error message

What is the best way to do that?

Thanks!