Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

将artDialog嵌套使用作为异步通信提示框时在ie8中focus方法出错 #40

Closed
quanz opened this issue Sep 11, 2013 · 5 comments

Comments

@quanz
Copy link

quanz commented Sep 11, 2013

artDialog很不错,不过有个小问题
如果将artDialog嵌套使用,如下面的例子,第一个对话框用于提问,在Save按钮则显示
提示框以进行异步操作,在ie8中
if (_activeElement) {
_activeElement.focus();
}
就出错了,_activeElement的计算是否有更合理的处理?

测试例子

    function test() {
        art.dialog({
            lock : true,
            content : 'Save?',
            button : [ {
                value : 'Save',
                focus : true,
                callback : doSave
            }, {
                value : 'Discard',
                callback : function(){
                }
            } ],
            cancel : function() {
            }
        });
    }
    
    function doSave() {
        var tip = art.dialog();
        tip.content("wait...");
        setTimeout(function(){
            tip.content("success").time(2000);  
        }, 2000);
    }
@qidizi
Copy link

qidizi commented Sep 22, 2013

a.com使用iframe包含了b.com.在b.com中使用这个js,那么在ie下面
document.activeElement属性将会导致无权访问而出错,整个js不能初始化.
临时使用try catch处理

@aui
Copy link
Owner

aui commented Sep 22, 2013

请问你的artDialog版本号是?IE版本是?

@qidizi
Copy link

qidizi commented Sep 22, 2013

ie10正常模式测试.
个人认为是焦点首先在top页面,获取时会无权限.
某人的解决方案是,先让本iframe:document.documentElement.focus();再取,只不过,看功能.
直接try catch,出错就不需要进行这步,毕竟重新的focus也是没必要了.
http://stackoverflow.com/questions/14378224/document-activeelement-in-iframe-shows-unspecified-error-in-ie-standards-mode

  • artDialog 5.0.3

@quanz
Copy link
Author

quanz commented Sep 26, 2013

我是ie8 + artDialog 5.0.4运行上面的例子出错,在ie8以上就没问题,跟了一下发现是后弹出的窗口关闭时试图恢复焦点,可 _activeElement却落在了前一个窗口的Save按钮上,而ajax操作是异步的,前一个窗口在后弹出的窗口关闭时应已经关闭了,有可能就因此出错了
看代码本身的注释是说这段代码用于“恢复焦点,照顾键盘操作的用户”,我现在的临时解决就是按qidizi所说
try catch不让出错,但没想清楚是否合适

@aui
Copy link
Owner

aui commented Dec 11, 2013

已经修复

@aui aui closed this as completed Dec 11, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants