Javascript Extjs:重定向到其他页面

Javascript Extjs:重定向到其他页面,javascript,extjs,extjs4,Javascript,Extjs,Extjs4,这是我的密码: Ext.onReady(function() { Ext.create('Ext.panel.Panel', { title: 'Results', width: 600, height: 400, renderTo: Ext.getBody(), items: [{ xtype: 'container', layout: 'fo

这是我的密码:

Ext.onReady(function() {
    Ext.create('Ext.panel.Panel', {
        title: 'Results',
        width: 600,
        height: 400,
        renderTo: Ext.getBody(),
        items: [{
                xtype: 'container',
                layout: 'form',
                style: 'width : 200px;margin-top: 10px ',
                items: [{
                    xtype: 'textfield',
                    fieldLabel: 'Name',
                    id: 'name',
                    style: 'width : 100px;'
                }]
            }, {
                xtype: 'container',
                layout: 'form',
                style: 'width : 200px;margin-top: 10px ',
                items: [{
                    xtype: 'datefield',
                    fieldLabel: 'Date',
                    id: 'date'

                }]
            }, {
                xtype: 'container',
                layout: 'form',
                style: 'width : 200px;margin-top: 10px ',
                items: [{
                    xtype: 'textfield',
                    vtype: 'email',
                    fieldLabel: 'EmailId',
                    id: 'email'

                }]
            }, {
                xtype: 'container',
                layout: 'form',
                style: 'margin-top: 10px ',
                items: [{
                    xtype: 'button',
                    text: 'signup',
                    float: 'right',
                    handler: function() {

                        Ext.Ajax.request({
                            method: 'GET',
                            url: 'rest/helloworld/',
                            disableCaching: false,
                            success: function() {
                                Ext.Msg.alert('', 'success');
                                Window.Location.assign('abc.js');

                            },
                            failure: function() {
                                Ext.Msg.alert('', 'failed');

                            },
                            params: {
                                name: Ext.getCmp('name').getValue(),
                                email: Ext.getCmp('email').getValue(),
                                date: Ext.getCmp('date').getValue()

                            }
                        });
                    }
                }]
            }

        ]

    });
});
一切进展顺利:

我真正需要的是在成功警报后加载另一个ExtJS页面

我尝试了
Window.Location.assign('abc.js')
,但它不起作用

Extjs的新特性

请提供帮助

您可以尝试:

window.location.assign("http://www.google.com");
或者只是:

location.assign("http://www.google.com");
甚至:

location.href = "http://www.google.com";
但是,如果将.js文件的名称作为参数传递,则只会使浏览器读取并显示它。也许您需要一个卡片布局,并在ExtJS应用程序的顶部放置另一个视图


如果您有卡片布局,您的链接将是您要显示的项目(卡片)的“#”+itemId。

问题1(与Ext JS无关):它不是
窗口。位置
,而是
窗口。位置

问题2(Ext JS问题):
Ext.Msg.alert
对话框是异步的。显示对话框后,而不是取消对话框后,
location.assign('www.google.com')
行将立即运行

要等到按下按钮之后,您必须向其传递回调

 Ext.Msg.alert('','success', function() {
     // Note that window is not necessary here, just location.assign will do
     window.location.assign('abc.js');
 });

这似乎是对浏览器将如何执行JS的误解。您不想将浏览器重定向到新的JS,而是在当前页面上加载新的JS。这可以通过告诉浏览器使用脚本标记获取JS来实现:

var newJs = document.createElement('script');
newJs.type = "text/javascript";
newJs.src = 'abc.js';
document.body.appendChild(newJs);
更常见的情况是,您已经在页面上加载了abc.js,并且需要在其上调用一个方法,或者转换到Ext面板或类似的东西。例如:

Ext.application({
    name : 'Fiddle',

    launch : function() {
        //this panel might be the contents of abc.js
        var abcPanel = Ext.create('Ext.panel.Panel', {
            title : 'Results',
            width : 600,
            height : 400,
            renderTo : Ext.getBody(),
            hidden: true
        });

        Ext.create('Ext.panel.Panel', {
            title : 'Results',
            width : 600,
            height : 400,
            renderTo : Ext.getBody(),
            items : [ {
                xtype : 'container',
                layout : 'form',
                style : 'width : 200px;margin-top: 10px ',
                items : [ {
                    xtype : 'textfield',
                    fieldLabel : 'Name',
                    id : 'name',
                    style : 'width : 100px;'
                } ]
            }, {
                xtype : 'container',
                layout : 'form',
                style : 'width : 200px;margin-top: 10px ',
                items : [ {
                    xtype : 'datefield',
                    fieldLabel : 'Date',
                    id : 'date'

                } ]
            }, {
                xtype : 'container',
                layout : 'form',
                style : 'width : 200px;margin-top: 10px ',
                items : [ {
                    xtype : 'textfield',
                    vtype : 'email',
                    fieldLabel : 'EmailId',
                    id : 'email'

                } ]
            }, {
                xtype : 'container',
                layout : 'form',
                style : 'margin-top: 10px ',
                items : [ {
                    xtype : 'button',
                    text : 'signup',
                    float : 'right',
                    handler : function() {
                        Ext.Ajax.request({
                            method : 'GET',
                            url : 'rest/helloworld/',
                            disableCaching : false,
                             success: function(){
                                 abcPanel.show();

                             },
                            failure: function(){
                                Ext.Msg.alert('','failed');

                            },
                            params : {
                                name : Ext.getCmp('name').getValue(),
                                email : Ext.getCmp('email').getValue(),
                                date : Ext.getCmp('date').getValue()

                            }
                        });
                    }
                } ]
            }

            ]

        });
    }
});

当你说一个新的Extjs页面时——你想完全转到一个不同的URL,或者你想在Ext中做一些特定的事情(比如显示一个不同的面板)。我怀疑你是否真的想向用户展示abc.js的内容,但也许我错了?是的,它只是在浏览器上读取文件,我想如何根据文件中的代码加载ui。是的,它只是在浏览器上读取文件,我想如何根据文件中的代码加载ui。为此,你不需要“window.location”。您可以将此文件中的组件放在顶部。一种方法是将它放在卡片布局中,并说它将成为活动项。请看以下内容:如果所有代码都存在于一个文件中,那么工作将非常好。。。。但是如果我把abcPanel放在另一个文件里。。。。这是吉文的错误。。。。无法读取null的属性“appendChild”。您没有document.body吗?