title: Checking iframe is called from the approved domain?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/5224286/how-to-limit-display-of-iframe-from-an-external-site-to-specific-domains-only">How to limit display of iframe from an external site to specific domains only</a>  </p>
  </blockquote>
  
  
  
  <p>What i want is simple. I want to prevent my website to be called from domains I did not approve.
  Let's say only a.com and b.com can have a page with an iframe calling my webapplication wwww.mydomain.com/myapp.php. How can I accomplish this?</p>
  
  <p>1st I was thinking about my web appplication checking the domain of the iframe's parent. Maybe that is possible, but certainly not easy, because of cross-domain restrictions.</p>
  
  <p>2nd I was thinking of having the requesting page on a.com and b.com execute a small PHP-script first which writes some info to a file or my database, so I know the requesting page is on one of the approved domains. The question is how to call and when to execute the script?  </p>
  
  <p>Is placing a script tag or image tag with a src attribute a good idea? That looks like a fairly simple solution to me and no PHP is required. The requesting page can be pure HTML.</p>
  
  <p>Should it look like this:</p>
  
  <pre><code>&lt;img src="http://wwww.mydomain.com/myapp.php" style="width: 0px; height: 0px;" alt="Not an image"  title="Not an image"/&gt;
  </code></pre>
  
  <p>What do you advice?</p>