I want to determine when the user clicks the link in iframeand changes the source iframe, because I want to resize it. I also use jQuery. What is the best way to detect this?
iframe
Actually I need something like this (this example is in jQuery, it does not work, I introduced this)
$('#iframe').live('load', function(){ alert('src is changed')});
You might want to use an event onLoad, as in the following example:
onLoad
<iframe src="/test.html" onLoad="alert(this.contentWindow.location);"></iframe>
iframe. , , IE5 Opera. ()
, contentWindow.location, iframe , onLoad .
contentWindow.location
, : , , iframe.
var prevSrc = ''; function check() { var curSrc = $('#iframe').attr('src'); if (curSrc != prevSrc) { // source has changed; do something prevSrc = curSrc; } } window.setInterval(check, 1000); // 1 sec - this can be anything you want