title: Alert when iframe url changed
body: <p>This script runs every 2 seconds and detect if the url of the iframe is changed. But I can't get it to work. I want to alert if the url of the iframe is changed. For example if someone clicks a link and go another page on the iframed content.</p>
  
  <pre><code>var prevSrc = "http://www.bodrumlife.com";
  function check() {
  var curSrc = $('#iframe').attr('src');
    if (curSrc != prevSrc) {
     alert("hobaa");
     prevSrc = curSrc;
     }
  }
  
  window.setInterval(check, 2000); // 2 seconds
  
  
  &lt;iframe id="iframe" name="iframe" src="http://www.bodrumlife.com"&gt;&lt;/iframe&gt;
  </code></pre>