window.close(); is not working in the latest Chrome Browser. is there any alternative?

3,922 views
Skip to first unread message

Emani Parida

unread,
Sep 13, 2016, 1:30:42 AM9/13/16
to Chromium-discuss
window.close(); is not working in the latest Chrome Browser. is there any alternative?

PhistucK

unread,
Sep 13, 2016, 7:34:52 AM9/13/16
to mail2ema...@gmail.com, Chromium-discuss
It should work, can you provide a URL with a simple test page that shows it does not work?


PhistucK

On Tue, Sep 13, 2016 at 7:17 AM, Emani Parida <mail2ema...@gmail.com> wrote:
window.close(); is not working in the latest Chrome Browser. is there any alternative?

--
--
Chromium Discussion mailing list: chromium...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-discuss

---
You received this message because you are subscribed to the Google Groups "Chromium-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-discuss+unsubscribe@chromium.org.

Emani Parida

unread,
Sep 14, 2016, 12:13:09 AM9/14/16
to Chromium-discuss
here is my sample project.

The window.close(); is in CloseDiv.aspx
WebSite1.rar

PhistucK

unread,
Sep 14, 2016, 1:50:33 AM9/14/16
to mail2ema...@gmail.com, Chromium-discuss
Most of the Chrome team does not have Visual Studio (or .NET Core or Mono or whatever) and cannot run ASPX files. Please, share a URL instead.


PhistucK

--

Emani Parida

unread,
Sep 14, 2016, 2:11:46 AM9/14/16
to PhistucK, Chromium-discuss
I have created the project for internal purpose.

PhistucK

unread,
Sep 14, 2016, 2:14:10 AM9/14/16
to Emani Parida, Chromium-discuss
No one has access to your localhost, this is a local URL.​


PhistucK

Emani Parida

unread,
Sep 14, 2016, 2:56:02 AM9/14/16
to PhistucK, Chromium-discuss
then publish that project in IIS ,and try to access it.

PhistucK

unread,
Sep 14, 2016, 2:57:38 AM9/14/16
to Emani Parida, Chromium-discuss
Yeah, no IIS here.


PhistucK

Emani Parida

unread,
Sep 14, 2016, 3:17:11 AM9/14/16
to PhistucK, Chromium-discuss
then enable IIS . 

PhistucK

unread,
Sep 14, 2016, 3:33:33 AM9/14/16
to Emani Parida, Chromium-discuss
​Why do you assume I use Windows?​

This group is trying to help you figure out your issue (since close() works for me in the simple case of creating a popup and then closing it using close()), so you need to provide a URL to a working (well, failing) test case if you want our help. JSFiddle, CodePen and plckr are good places for hacking up a test case.

You should not expect that people will install operating systems or servers in order to reproduce your issue...


PhistucK

Emani Parida

unread,
Sep 14, 2016, 4:54:25 AM9/14/16
to PhistucK, Chromium-discuss
Thanks. 

I have another alternative.

please check the JSFiddle   https://jsfiddle.net/qn9s8xmh/2/

Please create a html file and paste this code.
Then open that in IE and chrome.

PhistucK

unread,
Sep 14, 2016, 6:46:03 AM9/14/16
to Emani Parida, Chromium-discuss
plckr lets you serve individual files, so you might want to share a plckr instead. This way you only give a URL and it is enough.


PhistucK

Emani Parida

unread,
Sep 14, 2016, 7:12:33 AM9/14/16
to PhistucK, Chromium-discuss
just a simple script .

Is this working in your environment?

Please create a html page and paste this script 

<!DOCTYPE html>
<head>
    <title></title>
  

</head>
<body>
     <input id="Button1" type="button" value="button" onclick="window.close();" />
</body>
</html>

and run it with IE and chrome.

Hari krishna

unread,
Sep 14, 2016, 7:24:28 AM9/14/16
to Chromium-discuss, phis...@gmail.com
Hi Emani,

I think you can't close the browser window if that is what you intend to do. You can close the window which are opened by your scripts (See the example code here). 
If you have a script that opens window, share that script instead.


PhistucK



PhistucK

then enable IIS . 

Yeah, no IIS here.


PhistucK



PhistucK



PhistucK

To unsubscribe from this group and stop receiving emails from it, send an email to chromium-discu...@chromium.org.










Subhra jyoti Pradhan

unread,
Sep 14, 2016, 7:29:26 AM9/14/16
to mail2ema...@gmail.com, PhistucK, Chromium-discuss
First write code open the window and then apply window.close() to close it.

<button onclick="openWin()">Open "myWindow"</button>
 <button onclick="closeWin()">Close "myWindow"</button>

 <script>
        var myWindow;

        function openWin() {
            myWindow = window.open("", "myWindow", "width=200,height=200");
            myWindow.document.write("<p>This is 'Window'</p>");
        }

        function closeWin() {
            myWindow.close();
        }
</script>

PhistucK

unread,
Sep 14, 2016, 7:40:24 AM9/14/16
to Subhra jyoti Pradhan, Emani Parida, Chromium-discuss
Correct. Chrome never (intentionally, anyway) allowed windows that were not open by a script to be closed by a script.
If you had a different experience with Chrome, that was a bug, though I doubt that ever worked.


PhistucK

Sidney San Martín

unread,
Sep 14, 2016, 7:50:41 AM9/14/16
to mail2ema...@gmail.com, subhrajyo...@gmail.com, PhistucK, Chromium-discuss
I also think this is the issue. You can confirm by opening the console on the failing page, and you should see a warning if you weren't allowed to close it for this reason:



A page is generally allowed to close itself if it was opened by another page with window.open() or <a href="…" target="_blank">:



For window.open(), JavaScript on the original page is also allowed to close the window it opened:



Reply all
Reply to author
Forward
0 new messages