【问题标题】:IE9 and self.close()IE9 和 self.close()
【发布时间】:2011-05-23 17:01:52
【问题描述】:

我在 InnovaStudio WYSIWYG 编辑器 (5.3) 中有一个 iframe 的“弹出”窗口。它用于将导航链接放置到文本中。单击链接后,弹出窗口应关闭。

此代码适用于除 Internet Explorer 9 以外的所有浏览器:

$('#InternalLinkSelector').find('a').click(function(e) {
    e.preventDefault();
    $this = $(this);
    (opener ? opener:openerWin).oUtil.obj.insertLink($this.attr('href'), $this.html(), null, null);
    self.close();
});

弹出窗口的右上角有自己的关闭按钮,调用ISWindow.objs['UNIQUE_ID_STRING'].close();。我尝试重写代码以使用ISWindow,但它表现出相同的行为,适用于除 IE9 之外的所有浏览器:

$('#InternalLinkSelector').find('a').click(function(e) {
    e.preventDefault();
    $this = $(this);
    (opener?opener:openerWin).oUtil.obj.insertLink($this.attr('href'), $this.html(), null, null);
    // Find the window object to close it
    for (var i in top.ISWindow.objs) {
        if ('function' == typeof top.ISWindow.objs[i].close) {
            top.ISWindow.objs[i].close();
        }
    }
});

【问题讨论】:

  • 你试过window.close()

标签: javascript jquery


【解决方案1】:

尝试window.close() 而不是self.close()

【讨论】:

  • window.close() 的行为方式相同。
【解决方案2】:

我使用console.log(self.close) 并在 InnovaStudio 的istoolbar.js 代码中追踪到这些行:

me.rt.frm.contentWindow.closeWin=function() {
    me.close();
};
me.rt.frm.contentWindow.close=function() {
    me.close();
};

所以,考虑到 IE9 可能由于某种原因看不到 close(),我将代码更改为使用 closeWin()

$('#InternalLinkSelector').find('a').click(function(e) {
    e.preventDefault();
    $this = $(this);
    (opener ? opener : openerWin).oUtil.obj.insertLink($this.attr('href'), $this.html(), null, null);
    self.closeWin();
});

现在可以了!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-10-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-18
    • 2011-08-29
    • 2014-07-16
    相关资源
    最近更新 更多