Title: window.close call is not working
Tags: javascript;asp.net-mvc;javascriptmvc
Question: The window.close() method is not working in Chrome.
A "close" button exists in my Layout page with the JavaScript close method:
:javascript:window.open('', '_self','' );window.close();
<a  id="Close" href="javascript:window.open('', '_self','' );window.close();"&gt;Close</a&gt;
When tried to call a controller method which returns the VIEW, on click of close button (which is in layout.cshtml) does not work. It throws an error:
Scripts may close only the windows that were opened by it.
This works correctly in cases like returning a partial view.  IE has no issues.
Comment: don't use javascript: label in href, instead use onclick handler (and don't use the javascript: label).  See http://stackoverflow.com/a/11348403/61164

Comment: tried removing href, added event handler , but no luck.   $('#Close').click(function () {  window.close(); return false; });   Close

Comment: tried removing href, added event handler , but no luck.  (Layout.cshtml)
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")   $('#Close').click(function () {  window.close(); return false; });
Close

Comment: Please provide short example code showing the problem.



{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 0, 'CommentCount': 4, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2014:00:09/06/14', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<javascript><asp.net-mvc><javascriptmvc>', 'Title': 'window.close call is not working', 'ViewCount': 404, 'id': 25704257, 'user_AboutMe': None, 'user_AccountId': 4994059.0, 'user_DisplayName': 'Wcf Wcf', 'user_Reputation': 1.0, 'user_Views': 5.0, 'user_id': 4015291.0}}