Javascript IE9和self.close()
我在InnovaStudio所见即所得编辑器(5.3)中有一个iframed“弹出”窗口。它用于将导航链接放置到文本中。单击链接后,弹出窗口应关闭 此代码适用于除Internet Explorer 9以外的所有浏览器:Javascript IE9和self.close(),javascript,jquery,Javascript,Jquery,我在InnovaStudio所见即所得编辑器(5.3)中有一个iframed“弹出”窗口。它用于将导航链接放置到文本中。单击链接后,弹出窗口应关闭 此代码适用于除Internet Explorer 9以外的所有浏览器: $('#InternalLinkSelector').find('a').click(function(e) { e.preventDefault(); $this = $(this); (opener ? opener:openerWin).oUtil.
$('#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()
而不是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()
:
现在它工作了 你试过了吗?window.close()
window.close()
的行为方式与此相同。
$('#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();
});