使用js或jquery关闭“浏览器”选项卡 [英] Closing the Browser tab using js or jquery

查看:799
本文介绍了使用js或jquery关闭“浏览器”选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过点击按钮关闭当前的浏览器标签。 window.close方法不起作用。

I want to close the current browser tab by clicking a button. window.close method does not work.

推荐答案

您无法使用javascript关闭当前浏览器选项卡。如果站点在没有用户意图的情况下开始关闭自己,那么对于用户来说会很烦人,因此浏览器根本不允许这样做。不要忘记浏览器选项卡的概念未在HTML或EcmaScript规范中的任何位置定义,某些浏览器甚至没有标签。

You can't close the current browser tab with javascript. It would be annoying for the user if sites start to close themselves like this without the user intent so browsers simply do not allow this. Don't forget that the notion of a browser tab is not defined anywhere in the HTML nor the EcmaScript specifications, some browsers don't even have tabs.

您当然可以编写一个插件,您将在客户端的浏览器上安装该插件来完成这项工作。

You could of course write a plugin that you will install on your client's browser that will do the job.

这篇关于使用js或jquery关闭“浏览器”选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆