IE9和self.close()
我在InnovaStudio WYSIWYG Editor(5.3)中有一个iframed“弹出窗口”窗口。 它用于放置从导航到文本的链接。 单击链接后,弹出窗口应关闭。
此代码适用于除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.objs['
close '].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()
而不是self.close()
我使用了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(); });
现在它有效!