2011-05-23 36 views
2

我在InnovaStudio所見即所得編輯器(5.3)中有一個iframed「彈出式」窗口。它用於放置從導航到文本的鏈接。點擊鏈接後,彈出窗口應該關閉。IE9和self.close()

此代碼的工作,除了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(); 
     } 
    } 
}); 
+0

您是否嘗試過'window.close()' – Eduardo 2011-05-23 17:12:22

回答

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(); 
}); 

現在它的工作!

2

嘗試window.close()代替self.close()

+0

'window.close()'的行爲方式相同。 – Sonny 2011-05-23 17:47:22