简体   繁体   English

Javascript window.close在手机上

[英]Javascript window.close on mobile

I'm developing a small web app using ASP.NET. 我正在使用ASP.NET开发一个小型Web应用程序。 One of my function in this system is to open a new window tab, I've put a button close after they save the document but it seems it's only working on desktop. 在该系统中,我的功能之一是打开一个新的窗口选项卡,在保存文档后我将其关闭,但似乎只能在桌面上使用。

Here's my code. 这是我的代码。

<asp:Button ID="Button2" runat="server" Text="Close" OnClientClick="javascript: window.close();"/>

I'm using Opera mini as a browser in my mobile (SIII). 我将Opera mini用作移动设备(SIII)中的浏览器。

I fear you're out of luck, Opera Mini browser won't let you close windows with JavaScript, by design. 恐怕您不走运,O​​pera Mini浏览器无法让您通过JavaScript关闭窗口。

Taken from the official documentation : (emphasis mine) 摘自官方文件 :(强调我的)

Opening and closing windows 打开和关闭窗口

Opera Mini also doesn't support using JavaScript to open new windows (such as window.open()). Opera Mini也不支持使用JavaScript打开新窗口(例如window.open())。 If you use window.open() to launch a new window, Opera Mini will instead load that page as a new 'screen.' 如果使用window.open()启动新窗口,Opera Mini会将页面加载为新的“屏幕”。 It will not open a new window or tab. 它不会打开新的窗口或标签。 Similarly, because a new window was never opened, window.close() will not work . 同样,由于从未打开过新窗口,因此window.close()将不起作用 (This is also true of the target attribute of HTML.) (HTML的target属性也是如此。)

尝试这个

<asp:Button ID="Button2" runat="server" Text="Close" OnClientClick="return self.close();"/>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM