2012-08-11 96 views

回答

3

設置src屬性的iframe,你希望它開始加載(默認情況下它設置爲"")的那一刻:

$('#my-button').click(function() { 
    $('iframe#myIframe').attr('src', url); 
}); 

您也可以辦理的iframe完成時事件加載:

$('iframe#myIframe').load(function() { 
    // do stuff... 
}); 
+0

您需要的一切都在帖子中,您還想知道什麼? – WhyNotHugo 2012-08-12 22:25:53

0

所以我明白我需要什麼:

<iframe id="chgMe" src="Source1.htm">Frames are not supported on your browser.</iframe> 
<button onclick="document.getElementById('chgMe').src='Source2.htm'">Next</button> 
+0

由於他明確使用jQuery,因此不使用它的功能來獲取元素並設置src是沒有意義的。 – WhyNotHugo 2012-08-12 22:26:39