在给出window.close时,如何避免出现的确认框..? [英] On giving window.close ,how to avoid confirm box that is appearing..?

查看:189
本文介绍了在给出window.close时,如何避免出现的确认框..?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在asp.net2.0中的javascript上给出window.close(index.aspx);我收到一个确认框,因为正在查看的网页正在关闭?......如何避免这个确认框?



以下是我的代码:



In asp.net2.0 in javascript on giving window.close("index.aspx"); i am getting a confirm box as "the webpage yor are viewing is trying to close?..." how to avoid this confirm box?

following is my code:

<script type="text/javascript" >
function pageopen()
{
var Hid = document.getElementById('HiddenFieldCity');
var HidA = document.getElementById('HiddenFieldArea');
var HidC = document.getElementById('HiddenFieldComm');
var HidD = document.getElementById('txtDate');
if (document.getElementById('ddlone').value=="Select Here")
{
alert("Please Select City");
return false;
}
window.open('Home.aspx?hid=' + Hid.value + '& HidA=' + HidA.value + '& HidC=' + HidC.value + '& HidD=' + HidD.value + '',"Welcome","titlebar=0,fullscreen=0,addressbar=0,left=0,top=0,maximized=yes,width=1024,height=700,scrollbars=no,resizable=yes")
window.close("index.aspx");
}

推荐答案

试试这个片段。我希望它能起作用(例子)



Try this snippet. I hope it will work(Example)

<a href="" onclick="CloseWindow();">Close Window</a>










<script language=javascript>

function CloseWindow()

{

window.open('','_self','');

window.close();

}

</script>


问题



参考 - 绕过IE您正在查看的网页...弹出 [ ^ ]。

Problem

Refer - Bypass IE "The webpage you are viewing…" pop up[^].
引用:

您的JavaScript代码只能在没有先前由window.open()打开的确认的情况下关闭窗口。这是一种有意的安全预防措施,因为在网页上运行的脚本不拥有该窗口,关闭它会丢弃该窗口中的浏览历史记录。



解决方法是要么有一个欢迎页面,要么有某种页面弹出你想要用window.open关闭的窗口,或者告诉用户修改他们的浏览器安全设置以允许你的应用程序关闭他们的windows。

Your JavaScript code can only close a window without confirmation that was previously opened by window.open(). This is an intentional security precaution because a script running on a webpage does not own the window, and by closing it discards the browsing history in that window.

The workaround is to either have a "welcome page" or otherwise some sort of page that pops up the window you want to close with window.open in the first place, or to tell your users to modify their browser security settings to allow your application to close their windows.

所以,问题是你试图关闭index.aspx,你没有通过javaScript window.open打开它。你只能关闭由winow.open打开的窗口。



解决方案



在这种情况下,您可以尝试以下链接中提到的解决方法 -



1. 在IE7中没有提示消息的关闭窗口 [ ^ ]。

2. 您正在查看的网页正试图在Internet Explorer中关闭此窗口警告 [ ^ ]

So, the problem is that you are trying to close "index.aspx", which you have not opened by javaScript window.open. You can only close the window which is opened by winow.open.

Solution

In that case, you may try workarounds mentioned in the below links -

1. Close window without the prompt message in IE7[^].
2. The webpage you are viewing is trying to close this window warning in Internet Explorer[^]


这篇关于在给出window.close时,如何避免出现的确认框..?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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