iframe 跨域 contentdocument返回null

iframe 跨域 contentdocument返回null

js如何获取跨域iframe 里面content

跨域报错:

Blocked a frame with origin "http://xxx.com" from accessing a cross-origin frame

解决

  1. 跨域。。不能获取。。除非跨域的网站你有控制权postmessage 传递信息。。
  2. 一般涉及到跨域的话,都不去直接操作dom,都会想html5的on/postmessage一样。可以利用事件进行通讯。
  3. 将iframe的参数通过url传给父页面
posted @ 2022-03-21 15:08  zc-lee  阅读(1319)  评论(0编辑  收藏  举报