假设有页面A,里面有iframe标签Frame,iframe引用页面B,在页面B中写js来操作页面A。方法如下:

A.html

<iframe name="Frame" id="Frame" src="B.html" />

 在B页面的js中获取其所在的iframe:

var frame = window.parent.document.getElementById("Frame");

获取该iframe下的Document:

var cDocument = frame.contentWindow.document;

获取该iframe所在的Document:

var pDocument = window.parent.document;

然后便可执行各种操作

 

 

 

相关文章:

  • 2022-12-23
  • 2021-11-14
  • 2022-12-23
  • 2021-06-24
  • 2021-12-24
  • 2021-08-02
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-10-11
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案