IE9和self.close() [英] IE9 and self.close()
问题描述
我在InnovaStudio所见即所得编辑器(5.3)中有一个iframed弹出"窗口.它用于放置从导航到文本的链接.单击链接后,弹出窗口应关闭.
I have an iframed "pop-up" window in InnovaStudio WYSIWYG Editor (5.3). It is used to place a link from navigation into the text. Once a link is clicked, the pop-up should close.
此代码可用于除Internet Explorer 9之外的所有浏览器:
This code works in all browsers except 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之外的所有浏览器:
The pop-up has it's own close button in the upper corner that calls ISWindow.objs['
UNIQUE_ID_STRING'].close();
. I tried rewriting the code to use ISWindow
, but it exhibits the same behavior, working in all browsers but 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();
}
}
});
推荐答案
我使用了console.log(self.close)
并将其追溯到InnovaStudio的istoolbar.js
代码中的这些行:
I used console.log(self.close)
and traced it to these lines in InnovaStudio's istoolbar.js
code:
me.rt.frm.contentWindow.closeWin=function() {
me.close();
};
me.rt.frm.contentWindow.close=function() {
me.close();
};
因此,以为IE9由于某些原因可能看不到close()
,我将代码更改为使用closeWin()
:
So, thinking that IE9 may not be seeing the close()
for some reason, I changed my code to use 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();
});
现在可以了!
这篇关于IE9和self.close()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!