0

我必须制作一个表格,浏览器可以看到什么并保存密码。我发现了很多解决方案,并且在 Firefox 中——例如——用户owlness的解决方案非常好用。但是 Chrome 没有显示任何内容,控制台说:Uncaught TypeError: Cannot call method 'addUnits' of null

<form id="auth-form" action="" method="POST">
  <input id="auth-username" type="text" name="username" class="x-hidden">
  <input id="auth-password" type="password" name="password" class="x-hidden">
  <input id="auth-submit" type="submit" class="x-hidden">
</form>

...

       new Ext.FormPanel({
            region: 'south',
            //id: 'login',
            el: 'auth-form',
            autoShow: true,
            height: 125,
            title: 'Login',
            padding: 5,
            frame: true,
            labelWidth: 80,
            defaultType: 'textfield',
            defaults: {
                allowBlank: false,
                width: 250
            },

            items: [{
                fieldLabel: 'Username',
                el: 'auth-username',
                autoShow: true,
                inputType: 'text',
                //id: 'username',
                name: 'username'
            }, {
                fieldLabel: 'Password',
                el: 'auth-password',
                autoShow: true,
                inputType: 'password',
                //id: 'password',
                name: 'password'
            }],

            // auto focus ...

            // submit on enter ...

            buttons: [{
                text: 'Login',
                type: 'submit',
                //el: 'auth-submit',
                //autoShow: true,
                handler: function (button) {
                    var b = button; // scope
                    var f = b.ownerCt.ownerCt.getForm();
                    if (!f.isValid()) {
                        return;
                    }
                    f.standardSubmit = true;
                    b.ownerCt.disable();

                    MY.ajax.login({
                        scope: this,
                        success: function (res) {
                            f.submit();
                            win.close();
                        },
                        failure: function () {
                            b.ownerCt.enable();
                        },
                        params: f.getFieldValues()
                    });
                }
            }]
        })

你能帮我吗,我该怎么办?

4

1 回答 1

1

您可以将它们保存为 cookie:

Ext.util.Cookies.set('username', usernameValue, new Date().add(Date.DAY, 90));

// ...

items: [{
            fieldLabel: 'Username',
            el: 'auth-username',
            autoShow: true,
            inputType: 'text',
            //id: 'username',
            name: 'username',
            value: Ext.util.Cookies.get('username')
        }, {
            fieldLabel: 'Password',
            el: 'auth-password',
            autoShow: true,
            inputType: 'password',
            //id: 'password',
            name: 'password',
            value: Ext.util.Cookies.get('password')
        }]
于 2013-04-27T23:14:27.497 回答