0

On tens of other systems this works just fine. But, on one particular system, running IE11, a confirmation prompt is shown before closing the window. Other systems running IE11 do not exhibit this behavior.

Is there some setting in IE that would cause this? Or what else might I look for that is causing this on this particular system?

When the user clicks the link a new window is opened using...

$("a#offer").click(function (e) {
    e.preventDefault();
    var popUp = window.open("http://...", "thePopUp", "resizable=yes,height=" + (screen.availHeight-45) + ",width=760,left=" + ((screen.availWidth/2)-380) + ",menubar=no,scrollbars=yes,toolbar=no");
    popUp.focus();
});

Then in the new window, when they click a button the window closes:

$("#submit").click( function () {
    //...some sync ajax calls
    window.close();
});

enter image description here

  • Check security levels from that computer and compare it with others. – Justinas Nov 18 '14 at 13:52
  • If the page is not from the same site as the script that opened it, it is correct procedure to prompt you first. Also if whatever with `id="submit"` is an actual submit button, you want to cance. the submission too by using `$("form").on("submit",function(e) { e.preventDefault();... window.close();})` – mplungjan Nov 18 '14 at 13:52
  • @mplungjan Yes, it was a different domain URL. http://theinside.example.com vs http://inside.example.com Doesn't make sense as to why it was not an issue on other workstations. Thanks much! – Christopher Thomas Nicodemus Nov 18 '14 at 14:07

2 Answers2

1

If the page is not from the same site as the script that opened it, it is correct procedure to prompt you first.

In your case the DOMAIN is the same so you can set the document.domain to "example.com" in both pages and IE11 might be happier but please see this too:

"Access is denied" JavaScript error when trying to access the document object of a programmatically-created <iframe> (IE-only)

Also if whatever with id="submit" is an actual submit button, you want to cancel the submission too by using

$("form").on("submit",function(e) { 
  e.preventDefault();
  ... 
  window.close();
});
Community
  • 1
  • 1
mplungjan
  • 169,008
  • 28
  • 173
  • 236
-1

I'm not sure how it is working in other systems, however this should be a correct way.

You have to pass a reference object of opened window to close function.

$("#submit").click( function () {
    //...some sync ajax calls
    popUp.close();
});

See this: MDN

SK.
  • 4,174
  • 4
  • 30
  • 48
  • yes.. It will work but it will close the current window. What if I have to close a particular window. – SK. Nov 18 '14 at 14:53
  • Then you have to get the handle, but that was not the question. To get the handle from elsewhere (same origin) you can call open again with the name: `window.open("","windowName").close()` or `var popup=window.open("","windowName"); popup.close()` – mplungjan Nov 18 '14 at 18:01