Sonny
Sonny

Reputation: 8326

IE9 and self.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();
        }
    }
});

Upvotes: 2

Views: 6057

Answers (2)

Sonny
Sonny

Reputation: 8326

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!

Upvotes: 2

Naftali
Naftali

Reputation: 146300

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

Upvotes: 2

Related Questions