getElementById within iframe

别来无恙 提交于 2019-12-01 22:41:40

You will still be blocked by the same-origin policy if the domains mismatch. Doesn't matter if you're just trying to grab a value.

As Alex says on the comment above, you will still be blocked by the JavaScript 'same-origin' policy.

If your iframe is on the same domain, then you could try this:

document.getElementById('iframe-id').contentDocument.getElementById('canvas');

Assuming the iFrame has an assigned ID:

var iframe_div = document.getElementById('iframeid').document.getElementById('mydiv');
var content = iframe_div.innerHTML;

I believe should work.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!