在使用iframe时,经常需要获取其window对象,以及document对象,网上众说纷纭,兼容性好的方法如下:

 

1. iframe.contentWindow   

 

2. window.frames[index] 通过index获取iframe的window对象(ff和chrome不能通过name获取)

 

关于document对象的获取,很蹊跷(在opera上,始终有bug)

 

1. iframe.contentWindow.document

 

2. iframe.contentDocument (不通用)

相关文章:

  • 2021-05-31
  • 2022-12-23
  • 2021-12-26
  • 2022-01-06
  • 2022-02-22
  • 2022-12-23
  • 2021-11-28
猜你喜欢
  • 2021-07-15
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案