关闭浏览器标签 [英] closing browser tab

查看:91
本文介绍了关闭浏览器标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我单击菜单项时,网页会在新的浏览器选项卡中打开,但是现在我想在单击按钮时关闭浏览器选项卡.

when i click on menu item ,webpage opens in new browser tab but now i want close the browser tab when i click on button.

推荐答案

假设您如果要尝试从实际网页本身执行此操作,则可以使用self.close();在页面上的JavaScript中执行此操作.如果要关闭打开的窗口,则需要在创建它时捕获该窗口引用,然后才能关闭该窗口,如下所示:
Assuming that you are trying to do it from the actual webpage itself, you would use self.close(); to do this in JavaScript on the page. If you are trying to close a window you opened up, you need to capture the window reference when you create it, and then you can close that window like this:
popup_window = window.open("");
....
popup_window.close();


您可以使用javascript的window.close()函数来实现此目的.
You can use window.close() function of javascript to achieve this.


这篇关于关闭浏览器标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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