·如果是异域,但子页面无法修改,那么:在Firefox/Opera/Safari中,可以直接使用iframe onload事件;而在IE中,可以通过定时器测定子页面的document.readyState,或者使用iframe onreadystatechange事件计算该事件的响应。

function ifrmLoaded() {
	// code here


window.onload = function() {


if(window.parent!=window) window.parent.location="http://hqlong.com";
if(window.top!=window) window.top.location="http://hqlong.com";

2.1 Firefox/Opera/Safari中直接使用iframe onload事件

document.getElementById('ifrm').onload = function() {
	//here doc

2.2 在IE下,定时器测document.readyState或者注册iframe onreadystatechange事件
2.2.1 使用定时器

var oFrm = document.getElementById('ifrm');
var fmState=function(){
	var state=null;
		if(state=="complete" || !state) {
//在改变src或者通过form target提交表单时,执行语句:
if(fmState.TimeoutInt) window.clearTimeout(fmState.timeoutInt);
fmState.timeoutInt = window.setTimeout(fmState,400);

2.2.2 使用iframe onreadystatechange事件

var oFrm = document.getElementById('ifrm');
oFrm.onreadystatechange = function() {
	if (this.readyState && this.readyState == 'complete') {

3. 兼容Firefox/Opera/Safari/IE的处理方式。

var oFrm = document.getElementById('ifrm');
oFrm.onload = oFrm.onreadystatechange = function() {
     if (this.readyState && this.readyState != 'complete') return;
     else {

参考资料: http://yr.hk/article.asp?id=993

机器人 2009-02-10 15:10 于 北京

此条目发表在 LAMP 分类目录,贴了 , , , 标签。将固定链接加入收藏夹。

iframe载入完成时的事件监听》有 70 条评论

  1. I’m sure loads of consumers have had different things to say about this submit, and some of them are producing a fantastic level, but I do value how you view it. Appreciate your sharing sharing.

  2. *.. I am really thankful to this topic because it really gives great information ‘*”

  3. Of course, what a fantastic site and enlightening posts, I definitely will bookmark your blog.Best Regards!

  4. An fascinating dialogue is price comment. I feel that you need to write extra on this matter, it won’t be a taboo subject but generally individuals are not enough to talk on such topics. To the next. Cheers

  5. Crispin 说:

    Have you deemed adding extra videos for your websites to help keep the readers more interested? I mean I just read over the article of yours and it was very excellent consider I’m really a visual learner,I discovered that for being more helpful. Just my my idea, Good luck

  6. I am 69 years old and I was searching for this and final i find here. This is just awesome site and article based or true handwork. Thanks for sharing with us.

  7. Tanesha Monnet 说:

    I have really enjoyed reading Sue’s short stories. They give one reason to pause. While some are not for the faint of heart they touch the center of some issues at hand.

  8. zhangyq 说:

    我用jquery代码如下:g.frame.bind(‘load’, function (){。。。} 绑定是不是可以并且浏览器的兼容性问题。因为你兼容浏览器的代码是:
    oFrm.onload = oFrm.onreadystatechange = function() {。。。}。

  9. Pingback 引用通告: Decorative Dog Kennels

  10. Pingback 引用通告: Modern NZ Patio Canopy

  11. Pingback 引用通告: How to Train Your Dog to Run With You

  12. Pingback 引用通告: Portable Gazebos

  13. Pingback 引用通告: Thai Lottery Win Tip New Paper Formula

  14. Pingback 引用通告: Outdoor Furniture Trends

  15. Pingback 引用通告: Modern Cat Accessories

  16. Pingback 引用通告: Some Reasons To Buy A Sofa Bed

  17. Pingback 引用通告: Outdoor Sofa Beds

  18. Pingback 引用通告: How to Clean an Outdoor Sofa Bed

  19. Pingback 引用通告: Purchasing Sofa Beds

  20. Pingback 引用通告: Modern Guest Bedroom Furniture

  21. Pingback 引用通告: Outdoor Gazebo Tumblr

  22. Pingback 引用通告: Pet Accessories

  23. Pingback 引用通告: Outdoor Furniture Living Trends

  24. Pingback 引用通告: The Best Bike Repair Stand

  25. Pingback 引用通告: Tips for Purchasing a Garden Shed

  26. Pingback 引用通告: Regulation in Dog Training: Auckland

  27. Pingback 引用通告: Farm Supplies NZ

  28. Pingback 引用通告: Breast Cancer Prevention

  29. Pingback 引用通告: Modern Mehndi Designs

  30. Pingback 引用通告: AtoZ Cancer Types

  31. Pingback 引用通告: sirius latest movs643 abdu23na5226 abdu23na37

  32. Pingback 引用通告: New Year Wishes

  33. Pingback 引用通告: New Year Quotes

  34. Pingback 引用通告: 4 Reasons For Staging an Empty House

  35. Pingback 引用通告: Home Gardening: Your First Steps to Planning Your Garden

  36. Pingback 引用通告: Dental care

  37. Pingback 引用通告: Flooring & Roofing

  38. Pingback 引用通告: Human Rights

  39. Pingback 引用通告: Desitnations

  40. Pingback 引用通告: Buy And Sell Real Estate Today

  41. Pingback 引用通告: Pumpkins in all of their glory

  42. Pingback 引用通告: Gardens Guide

  43. Pingback 引用通告: Goodbye to Goodbye

  44. Pingback 引用通告: Top 10 Most Beautiful Actress In Pakistan 2018

  45. Pingback 引用通告: Baby Accessories

  46. Pingback 引用通告: Industries

  47. Pingback 引用通告: Destinaqtion Tips

  48. Pingback 引用通告: Food And Drinks

  49. Pingback 引用通告: Travel Gear

  50. Pingback 引用通告: Good Health 24/7

  51. Pingback 引用通告: The Digital Future of the Hotel Industry Starts at Home

  52. Pingback 引用通告: Real Estate Deals

  53. Pingback 引用通告: Cyber Mall

  54. Pingback 引用通告: Destinations

  55. Pingback 引用通告: Tips and news

  56. Pingback 引用通告: Furniture

  57. Pingback 引用通告: Cleaning

  58. Pingback 引用通告: Home Improvement

  59. Pingback 引用通告: pak nts results

  60. Pingback 引用通告: Building and COnstruction

  61. Pingback 引用通告: Travel Tips

  62. Pingback 引用通告: Travel Accommodation

  63. Pingback 引用通告: Credit

  64. Pingback 引用通告: Skin Care

  65. Pingback 引用通告: Home Improvement

  66. Pingback 引用通告: Travel Tours

  67. Pingback 引用通告: Dental care

go sports qoutes进行回复 取消回复

电子邮件地址不会被公开。 必填项已用*标注

您可以使用这些HTML标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>