最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

javascript - IE9 and self.close() - Stack Overflow

matteradmin5PV0评论

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.

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

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

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.

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

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();
        }
    }
});
Share Improve this question asked May 23, 2011 at 17:01 SonnySonny 8,3467 gold badges65 silver badges137 bronze badges 1
  • have you tried just window.close() – Eduardo Commented May 23, 2011 at 17:12
Add a ment  | 

2 Answers 2

Reset to default 2

Try window.close() instead of self.close()

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

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

Now it works!

Post a comment

comment list (0)

  1. No comments so far