在警告消息中单击确定后如何关闭浏览器中的当前窗口? [英] How to close the current window in browser after clicking ok in the alert message?

查看:89
本文介绍了在警告消息中单击确定后如何关闭浏览器中的当前窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基于页面中的某些操作,我想给用户发送一条警告消息(即:您的简历已经上传),并且我希望关闭该窗口,当用户在该警报中单击确定时框。我只想使用alert方法而不是javascript中的确认方法。为什么因为警报方法给出了唯一的选项确定,如确认方法给出是或否。任何人都可以帮助我。

  alert(ok); 
window.close();

在Ankit对OP的评论之后进行编辑:请注意,如果您没有用Javascript自己打开窗口,您可能无权关闭它,具体取决于浏览器。


based on some actions in a page , I want to give an alert message to the user (ie.. your resume has been uploaded.) like that and i want to close that window, when the user clicks okay in that alert box. I want to do this using alert method only instead of confirm method in javascript. why because alert method gives the only option "ok" where as confirm method gives " yes or no" .can anyone help me please.

解决方案

Just put the statements one after each other :

alert("ok");
window.close();

EDIT following Ankit's remark to OP : note that if you didn't open the window with Javascript yourself, you may not be authorized to close it depending on the browser.

这篇关于在警告消息中单击确定后如何关闭浏览器中的当前窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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