ExtjS的window内嵌入iframe的使用方法

本文介绍如何在ExtJS中使用Window组件嵌入iframe,避免页面过于臃肿。通过创建一个按钮,点击按钮弹出一个含有iframe的窗口,iframe加载指定网页。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

使用Extjs的时候经常要用的一种方法,有的时候不能把HTML页面都放在一个window里面,那样页面很非常庸肿,而是用iframe来设置嵌套 直接看效果吧


程序代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>EXTJS-window弹出窗口</title>
    <link href="../ext-3.2.2/resources/css/ext-all.css" rel="stylesheet" type="text/css" />

    <script src="../ext-3.2.2/adapter/ext/ext-base.js" type="text/javascript"></script>

    <script src="../ext-3.2.2/ext-all.js" type="text/javascript"></script>

    <script type="text/javascript">
    Ext.onReady(function(){   
        var win;
        var button= new Ext.Button({
       // renderTo:Ext.getBody(),
        renderTo:’button1′,
        text:"点击打开窗口",
        listeners:{
        "click":function()     {    
        if(!win){
            win = new Ext.Window({
                applyTo:’hello-win’,
                title:’新建的窗口’,
                layout:’fit’,
                width:640,
                height:480,
                closeAction:’hide’,
                plain: true,               

                items: [{  title: '弹出的窗口',
                                    header:false,
                                    html : '<iframe style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; width: 728px; height: 455px; border-right-width: 0px" src=http://www.google.com frameborder="0" width="100%" scrolling="no" height="100%"></iframe>',
                                    border:false
                                }]

            });
        }
        win.show(this);
             }
        }    
        });
    });

    </script>

</head>
<body>
    <div id="button1">
    </div>
    <div id="hello-win" class="x-hidden">
</body>
</html>

不多说了, 代码很简单, 主要是在window中内嵌入iframe.

本站文章除注明转载外,均为本站原创编译

转载请注明:文章转载自: 翟子博客 [ http://blog.foreverlove.us/]

本文标题:ExtjS的window内嵌入iframe的使用方法
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值