如何通过javascript关闭当前的winow [英] How to close the current winow by javascript

查看:89
本文介绍了如何通过javascript关闭当前的winow的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要关闭显示我的网页的标签,



。但浏览器不允许通过javascript关闭窗口,只要它没有被javascript打开



i有两个div当secound div显示我想要一个警报并关闭当前窗口..



注意-i没有通过javascript

I need to close the tab which displays my webpage,

on the load . But browser does not allow to close the window by javascript as long as it is not opened by javascript

i have two div when secound div display i want an alert and close the current window..

Note -i have not opend the tab(window) by javascript

推荐答案

打开标签(窗口)您所经历的是保护浏览器的一部分,让您在野外......

从代码中关闭(和打开)窗口被视为弹出活动,并且不被允许 - 默认情况下。

因此在执行window.close()时;浏览器会向用户发送一条消息,并询问他是否同意关闭窗口...唯一的例外是window.open()打开窗口时,这不是你的情况。

你必须考虑你的应用程序设计......
What you have experienced is part of the 'protection' browsers give you while on the wild...
Closing (and opening) windows from code is considered 'popup' activity and not tolerated - by default.
So when executing window.close(); browsers will send the user a message, and ask if he agree to close the window...The only exception is when the window was opened by window.open(), which is not your case.
You have to consider your application design...


close()方法关闭当前窗口。



The close() method closes the current window.

<form method="post">
<input type="button" value="Close Window">
onclick="window.close()">
</input></form>





一些参考.. :)





Window.Close



Window.Close方法示例



HTML关闭窗口代码


嗨Umesh,

<你可以试试这个链接



http://www.w3schools.com/jsref/met_win_close.asp [ ^ ]



祝你好运
Hi Umesh,

you can try this link

http://www.w3schools.com/jsref/met_win_close.asp[^]

Good Luck


这篇关于如何通过javascript关闭当前的winow的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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