加载由jquery附加的iframe后,我可以调用一个函数吗? [英] Can I call a function after the loading of an iframe appended by jquery?

查看:110
本文介绍了加载由jquery附加的iframe后,我可以调用一个函数吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码

 < div id =myContent>< / div> 

$('#myContent')。html '< iframe height =200frameborder =0src =www.google.com>< / iframe>');

,并且我希望当框架中的整个页面完全加载时,调用一个函数,如 alert(我已完成) ;



我该怎么做?

PS不知道为什么jsfiddle不会捕捉到谷歌页面:)

解决方案

您可以通过事件。load()(查看api了解更多信息)。



示例:

  $('#myContent')。html('< iframe id =winIdheight =200frameborder =0src =www.google.com>< / iframe>'); 
$ b $('#winId')。load(function(){alert('loaded')})


This is my code :

​<div id="myContent​​​​​​​"></div>​

$('#myContent').html('<iframe height="200" frameborder="0" src="www.google.com"></iframe>');​

and I'd like, when the whole page in the frame is totally loaded, call a function, like alert("I'm finished");.

How can I do it?

P.S. dunno why jsfiddle doesnt catch the google page :)

解决方案

You can do it with the event .load() (Check the api for more info).

Example:

$('#myContent').html('<iframe id="winId" height="200" frameborder="0" src="www.google.com"></iframe>');

$('#winId').load(function() {alert('loaded')})

这篇关于加载由jquery附加的iframe后,我可以调用一个函数吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆