man*_*man 4 iframe jquery load
您好,我正在使用一个按钮来更改iframe的src,当我单击它时:
$("#iframe").attr('src',"someurl");
Run Code Online (Sandbox Code Playgroud)
有没有办法在加载新URL之前显示"请稍候"消息或gif加载程序?
为什么不使用具有回调来管理显示文本的jQuery.load函数:
HTML
<button id="myLoadButton">Load</button>
<div id="Myiframe"></div>
Run Code Online (Sandbox Code Playgroud)
JS
$('#myLoadButton').click(function(){
$(this).text('Please wait...');
$('#Myiframe').load('ajax/test.html', function(){
$('#myLoadButton').text('Content loaded!');
});
})
Run Code Online (Sandbox Code Playgroud)