如何避免使用javascript的window.close时弹出确认关闭窗口?

更新于
2026-09-28 02:30:22
2阅读来源:SEO问题
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计235个文字,预计阅读时间需要1分钟。

如何避免使用javascript的window.close时弹出确认关闭窗口?

在JavaScript中,使用`window.close`前添加以下代码可以避免弹窗提示:

javascriptwindow.opener=null;window.open('', '_self');

如何避免使用javascript的window.close时弹出确认关闭窗口?

这里`window.opener`引用的是通过`window.open`打开的页面。本教程操作环境:Windows 7系统、JavaScript 1.8.5版本。

在javascript中,可以在window.close前添加“window.opener=null;window.open('','_self');”语句设置不提示弹窗。window.opener引用的是window.open打开的页面。

本教程操作环境:windows7系统、javascript1.8.5版、Dell G3电脑。

在window.close();?前加上

window.opener = null; window.open('', '_self');

就不会提示’是否要关闭本窗口’了!

所以打开新的网页并且关闭当前页面的方法是:

window.open(newurl); window.opener = null; window.open('', '_self'); window.close();

其中newurl为要转向页面的URl。

以上就是javascript中window.close如何不提示弹窗的详细内容,更多请关注自由互联其它相关文章!

本文共计235个文字,预计阅读时间需要1分钟。

如何避免使用javascript的window.close时弹出确认关闭窗口?

在JavaScript中,使用`window.close`前添加以下代码可以避免弹窗提示:

javascriptwindow.opener=null;window.open('', '_self');

如何避免使用javascript的window.close时弹出确认关闭窗口?

这里`window.opener`引用的是通过`window.open`打开的页面。本教程操作环境:Windows 7系统、JavaScript 1.8.5版本。

在javascript中,可以在window.close前添加“window.opener=null;window.open('','_self');”语句设置不提示弹窗。window.opener引用的是window.open打开的页面。

本教程操作环境:windows7系统、javascript1.8.5版、Dell G3电脑。

在window.close();?前加上

window.opener = null; window.open('', '_self');

就不会提示’是否要关闭本窗口’了!

所以打开新的网页并且关闭当前页面的方法是:

window.open(newurl); window.opener = null; window.open('', '_self'); window.close();

其中newurl为要转向页面的URl。

以上就是javascript中window.close如何不提示弹窗的详细内容,更多请关注自由互联其它相关文章!