如何使用jQuery获取iFrame加载事件 [英] How to get iFrame load event using jQuery
本文介绍了如何使用jQuery获取iFrame加载事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好Guyz,
我在我的一个页面中有类似的场景,正在加载iFrame,在iFrame上我需要使用jQuery绑定一个click事件,为此,我尝试了以下代码:
$ j(' .ms-dlgFrame')。load( function (){
$ j( ' 。ms-dlgFrame')。contents()。find(' a [title =Browse]')。bind(' click ', function (){
console .log(' Frame Loaded');
setTimeout( function (){
console .log(' 在Timerout'之后加载的函数);
$ j(' 。ms-dlgFrame')。each( function (){
$ j( this )。contents()。find(' #resultcontent')。css(' height',' 200px');
$ j ( this )。contents()。find(' # MetadataTreeControlTreeSearch')。css(' height',' 200px');
});
}, 5000 );
});
});
但没有运气。我无法触发click事件。尝试了许多技巧,但对我没有用。任何有关如何使用jQuery绑定iFrame元素的click事件的帮助都将非常感激。
解决方案
j(' 。ms-dlgFrame')。load( function (){
j(' 。ms-dlgFrame')。contents()。find(< span class =code-string>' a [title =Browse]')。bind(' 点击, function (){
console .log(' Frame Loaded');
setTimeout( function (){
console .log(' 在Timerout'之后加载的函数);
j(' 。ms-dlgFrame')。each(< span class =code-keyword> function (){
Hi Guyz,
I have scenraio like in one of my Page, iFrame is being loaded, over that iFrame I need to bind a click event using jQuery, for that I have tried below code:
$j('.ms-dlgFrame').load(function(){ $j('.ms-dlgFrame').contents().find('a [title="Browse"]').bind('click', function(){ console.log('Frame Loaded'); setTimeout(function(){ console.log('Function Loaded after Timerout'); $j('.ms-dlgFrame').each(function(){ $j(this).contents().find('#resultcontent').css('height','200px'); $j(this).contents().find('#MetadataTreeControlTreeSearch').css('height','200px'); }); },5000); }); });
but there was not luck. I could not get the click event fired. Tried lot of tricks to achieve but did not work for me. Any help over how to bind a click event of iFrame element using jQuery would be much appreciated.解决方案j('.ms-dlgFrame').load(function(){
j('.ms-dlgFrame').contents().find('a [title="Browse"]').bind('click', function(){ console.log('Frame Loaded'); setTimeout(function(){ console.log('Function Loaded after Timerout');
j('.ms-dlgFrame').each(function(){
这篇关于如何使用jQuery获取iFrame加载事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文