动态地在页面中插入 iframe,再获取里面的 canvas 元素,想要设置其尺寸。但是跨域报错了:
Uncaught DOMException: Blocked a frame with origin "null" from accessing a cross-origin frame.
let iframeNew = `<iframe src="source/${entity}.html" id="sourceAni" name="source"></iframe>`;
$('#meaning').prepend(iframeNew);
$('#sourceAni').on('load', function() {
console.log(document.getElementById('sourceAni').contentWindow.document.getElementById('canvas'));
});
在网上查到的解决办法都是把页面放到服务器环境运行,但是我做的项目要求可以离线使用。请问各位还有什么办法吗?
相关问题
- how to get selected text from iframe with javascri
- How do you scroll an iframe from within using jque
- Is there any way to make the background of a 3D-mo
- Iframe scrollbar align to right
- I would like to manipulate the html inside an ifra
相关文章
- iframe的里内容看不到,但却点得到
- tp5.1.前后端分离.cros跨域问题.在线上找了各种方法.没辙了
- netcore3.1 WebApi独立运行跨域设置无效
- iframe content disappears on Firefox
- Changing an IFrames InnerHtml from codebehind
- Scrolling issues with ExtJS 5 app inside IFrame
- iframe not reading cookies in Chrome
- Does html5 local storage store per iframe?
https://www.cnblogs.com/sunshine-wy/p/8891033.html 试试这个
后来我把调整画布尺寸的脚本引入到子页面,解决了问题。