iframe的Javascript动态创建;t加载src
Javascript dynamic creation of iframe doesn't load src
我有下面的一段代码,应该以谷歌主页为例动态加载iframe。创建了iframe,但没有加载src:
var theIframe2 = document.createElement("iframe");
theIframe2.setAttribute("id", "main-iframe2");
theIframe2.setAttribute("src", "http://www.google.co.uk");
theIframe2.style.width = "300px";
theIframe2.style.height = "200px";
theIframe2.style.position = "absolute";
theIframe2.style.top = "0px";
theIframe2.frameBorder = 1;
var containerDiv2 = document.getElementById('container');
containerDiv2.appendChild(theIframe2);
它也在jsfiddle上:http://jsfiddle.net/JxhFE/1/
如有任何建议,我们将不胜感激。
谢谢,科林。
您不能在域中的IFrame
中显示google.co.uk
。由于安全原因,Google
只允许从同一来源嵌入其主页。(X-Frame-Options SAMEORIGIN
标头。)
相关文章:
- 使用:new Image()控制加载html.src=html_URL
- Grunt 可以直接从文件对象/数组或 glob 中的“src”值通过 HTTP 加载远程文件
- 将 src 内容动态加载到 SVG 图像
- 如果有办法在 N 秒内加载未触发,则有没有办法设置 img src
- 如何从调整大小或拉伸的src加载图像
- 未加载JavaScript src文件
- 防止iFrame src在加载时在单击时被触发
- 将图像加载到localStorage,并将图像src设置到该位置
- Javascript src加载顺序
- 加载除键外具有相同src的多个iFrame
- 加载后修改页面上所有没有id的图像(src)
- Jasmine 不从“src”目录加载 js 文件
- 延迟加载引导传送带而不更改 img src 属性
- 视频 src 不会在单击其他对象时重新加载
- 加载 Iframe src,并从水平下拉菜单中进行选择
- 没有物品的中继器中的角加载 img src
- 加载src属性中带有可变参数的javascript
- 加载src-iframe的文档后调整其大小
- iframe的Javascript动态创建;t加载src
- 如何在.load()中加载(src=..) js文件