From the main window, another window opens in which the content inside the iframe is displayed. There is a button in the content that calls window.close (). This button does not work. Is it possible to close the window in which the content is displayed using this button without changing the code in the content? For example, hang some handler.

  • An important point, all in the same domain? - Duck Learns to Take Cover
  • In different domains. - Vladimir Smirnov
  • That is, correctly, I understand that you just do not want to show your site in frames? This is usually not decided by the client, but by setting the server header. Typically, frame access to the parent window is window.top or window.parent. But simply window.top.close () most likely will not work due to security restrictions, and even from a frame loaded from another domain. - Duck Learns to Take Cover
  • If you want to close the frame itself, and not the parent window, and it does not close, then for this there is a chrome-only hack: window.open (location, '_self'). Close (); Because generally speaking, in extreme specs, only windows that are open from js (security restrictions) can be closed from js - Duck Learns to Hide
  • Those. in fact, you can only do window.close for windows that are created through window.open. At least cross-browser. - Duck Learns to Take Cover

0