使用JavaScript创建IFRAME [英] Creating an IFRAME using JavaScript

查看:691
本文介绍了使用JavaScript创建IFRAME的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在线托管的网页,我希望有可能使用一些JavaScript将IFRAME插入到另一个网页上。

I have a webpage hosted online and I would like it to be possible that I could insert an IFRAME onto another webpage using some JavaScript.

这是怎么回事?最好的方法,我只是将我的网页网址添加到JavaScript并且它适用于所有浏览器?

How would this be the best way possible, that I just add my webpage URL to the JavaScript and that it work on all browsers?

谢谢

推荐答案

您可以使用:

<script type="text/javascript">
    function prepareFrame() {
        var ifrm = document.createElement("iframe");
        ifrm.setAttribute("src", "http://google.com/");
        ifrm.style.width = "640px";
        ifrm.style.height = "480px";
        document.body.appendChild(ifrm);
    }
</script> 

还要检查 iFrame元素的基础知识

这篇关于使用JavaScript创建IFRAME的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆