如何防止更改的页面关闭??? [英] How to prevent a changed page from beeing closed???

查看:86
本文介绍了如何防止更改的页面关闭???的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我遇到了以下问题:我有一个页面(leta ?? s调用此页面page1.aspx),其中包含一些TextBoxes和一个打开另一个页面的超链接(leta ?? s将此页面称为page2.aspx)作为弹出窗口使用window.open或window.showModalDialog。因为当我们试图关闭page1.aspx并且在此期间更改了值时,我想要警告我的应用程序的用户我想到了使用a ?? onbeforeunloada ?? page1.aspx正文的事件。不幸的是,当链接被点击时,此事件也会触发,这不是我想要的。

是否有人知道如何处理页面的关闭事件,同时能够打开我页面的链接?我知道它可以以某种方式完成,因为我已经在MS CRM中看到了这种行为..


我试过以下


< ;%@ Page Language =" vb" AutoEventWireup = QUOT假QUOT;代码隐藏= QUOT; WebForm1.aspx.vb" Inherits =" ATV2004.WebForm1"%><!DOCTYPE HTML PUBLIC" - // W3C // DTD HTML 4.0 Transitional // EN">< HTML>< HEAD>< title> WebForm1< / title>< meta name =" vs_snapToGrid" content =" True">< meta name =" vs_showGrid" content =" True">< meta name =" GENERATOR" content =" Microsoft Visual Studio .NET 7.1"< meta name =" CODE_LANGUAGE" content =" Visual Basic .NET 7.1">< meta name =" vs_defaultClientScript" content =" JavaScript">< meta name =" vs_targetSchema" content =" http://schemas.microsoft.com/intellisense/ie5">< script language =" javascript"><! -


函数SetPageToChanged( )

document.Form1.txtChanged.value =" 1"

函数CheckIfPageHasChanged()

if(document.Form1.txtChanged.value ==" 1"


event.returnValue =" \ n\ n -------------------- -------------------------------------------------- ---------------------------------------- \\\
要保存更改,请单击取消,然后单击保存或保存并关闭。\ n禁止关闭此记录而不保存更改,单击确定。\ n --------------------- -------------------------------------------------- --------------------------------------- \\\
"

函数PopUpMyWindow(){

window.showModalDialog(''WebForm2.aspx'',window,''Ful lscreen = no; Scrollbars = no; Menubar = no; Locationbar = no ; Resizable = no; Status = no; dialogWidth = 450px; dialogHeight = 400px;'')

// - >< / script>< / HEAD>< body onbeforeunload =" CheckIfPageHasChanged()"> ;< form id =" Form1"方法= QUOT;交" runat =" server">& nbsp;& nbsp;& nbsp


< input type =" hidden" id =" txtChanged">< a href =" javascript :PopUpMyWindow()">这是一个链接。< / a>< input type =" text" onBlur =" javascript :SetPageToChanged();">< / form>< / body>< / HTML


谢谢你你的帮助

Daniel Walzenbac

Hi

I am faced with the following problem: I have a page (leta??s call this page page1.aspx) containing some TextBoxes and a hyperlink which opens another page (leta??s call this page page2.aspx) as a popup using either window.open or window.showModalDialog. Since I want to warn the users of my application when they try to close page1.aspx and have changed the values in the meantime I thought about using the a??onbeforeunloada?? event of the body of page1.aspx. Unfortunately this event also fires when the link gets clicked which is NOT intended by me.
Does anybody know how I can handle the close event of the page while being able to open links of my page? I know that it can somehow be done since Ia??ve seen this behaviour in MS CRM..

I tried the following

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="ATV2004.WebForm1"%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML><HEAD><title>WebForm1</title><meta name="vs_snapToGrid" content="True"><meta name="vs_showGrid" content="True"><meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1"><meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1"><meta name="vs_defaultClientScript" content="JavaScript"><meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5"><script language="javascript"><!-

function SetPageToChanged()
document.Form1.txtChanged.value="1"
function CheckIfPageHasChanged()
if (document.Form1.txtChanged.value == "1"

event.returnValue = "\n\n--------------------------------------------------------------------------------------------------------------\nTo save your changes, click Cancel, and then click Save or Save and Close.\n\nTo close this record without saving your changes, click OK.\n--------------------------------------------------------------------------------------------------------------\n"

function PopUpMyWindow(){
window.showModalDialog(''WebForm2.aspx'',window,''Ful lscreen=no; Scrollbars=no; Menubar=no; Locationbar=no; Resizable=no; Status=no; dialogWidth=450px; dialogHeight=400px;'')

//--></script></HEAD><body onbeforeunload="CheckIfPageHasChanged()"><form id="Form1" method="post" runat="server">&nbsp;&nbsp;&nbsp

<input type="hidden" id="txtChanged"><a href="javascript:PopUpMyWindow()">This is a link.</a><input type="text" onBlur="javascript:SetPageToChanged();"></form></body></HTML

Thank you for your help
Daniel Walzenbac

推荐答案

嗨丹尼尔,


您应该在Internet Explorer客户端开发中发布此问题

组。他们可以帮助您编写客户端代码。


Jim Cheshire,MCSE,MCSD [MSFT]

ASP.NET

开发人员支持
ja******@online.microsoft.com


此帖子按原样提供,不提供任何保证,也不授予任何权利。

------------------- -
Hi Daniel,

You should post this question in the Internet Explorer client development
groups. They can assist you with writing client-side code.

Jim Cheshire, MCSE, MCSD [MSFT]
ASP.NET
Developer Support
ja******@online.microsoft.com

This post is provided as-is with no warranties and confers no rights.
--------------------
Thread-Topic:如何防止更改的页面被关闭???
thread-index:AcPvHj7cM4M4jlZyTGCzRjdtRTekVg ==
X-Tomcat-NG:microsoft.public。 dotnet.framework.aspnet
来自:" =?Utf-8?B?RGFuaWVsIFdhbHplbmJhY2g =?="
< da ********************** @ freudenberg.de>主题:如何防止更改的页面被关闭???
日期:2004年2月9日星期一07:06:07 -0800
行数:32
消息ID:< 58 **************** ******************@microsoft.co m>
MIME-Version:1.0
内容类型:text / plain;
charset =" Utf-8"
Content-Transfer-Encoding:8bit
X-Newsreader:适用于Windows 2000的Microsoft CDO
内容类:urn:content-classes:message
重要性:正常
优先级:正常
X-MimeOLE:由Microsoft MimeOLE制作V6.00.3790.0
新闻组:microsoft.public.dotnet.framework.aspnet
路径:cpmsftngxa07。 phx.gbl
外部参照:cpmsftngxa07.phx.gbl microsoft.public.dotnet.framework.aspnet:208562
NNTP-Posting-Host:tk2msftcmty1.phx.gbl 10.40.1.180
X-Tomcat -NG:microsoft.public.dotnet.framework.aspnet




我遇到了以下问题:我有一个页面(leta ?? s称之为

page page1.aspx)containi一些TextBoxes和一个打开的超链接

另一个页面(leta ?? s调用此页面page2.aspx)作为弹出窗口使用

window.open或window.showModalDialog 。因为我想在我们的

应用程序的用户试图关闭page1.aspx并且在此期间更改了值

时,我想要使用a ?? ?? onbeforeunloada? page1.aspx的

正文事件。不幸的是,当链接获得点击时,此事件也会触发,这不是我想要的。

是否有人知道如何处理页面的关闭事件/>
能够打开我的页面链接吗?我知道它可以以某种方式完成,因为

我在MS CRM中看到过这种行为......


我尝试了以下内容:


<%@ Page Language =" vb" AutoEventWireup =" false"
Codebehind =" WebForm1.aspx.vb" Inherits =" ATV2004.WebForm1"%><!DOCTYPE HTML

PUBLIC" - // W3C // DTD HTML 4.0

Transitional // EN"> ;< HTML>< HEAD>< title> WebForm1< / title>< meta

name =" vs_snapToGrid" content =" True">< meta name =" vs_showGrid"

content =" True">< meta name =" GENERATOR" content =" Microsoft Visual Studio .NET

7.1">< meta name =" CODE_LANGUAGE" content =" Visual Basic .NET 7.1"< meta

name =" vs_defaultClientScript" content =" JavaScript">< meta

name =" vs_targetSchema"

content =" http://schemas.microsoft.com/intellisense/ie5" ;>< script

language =" javascript"><! -


函数SetPageToChanged(){

document.Form1.txtChanged.value =" 1";

}

函数CheckIfPageHasChanged(){

if(document.Form1 .txtChanged.value ==" 1")

{

event.returnValue =

" \ n\\\
-- -------------------------------------------------- -------------------

----------------------- ---------------- \ n要保存更改,请单击

取消,然后单击保存或保存并关闭。\ n禁止关闭此记录

而不保存您的更改,请单击

OK.\ n --------------------- --------------------------------------------------

--------------------------------------- \ n" ;;

}

}


函数PopUpMyWindow(){

window.showModalDialog(''WebForm2.aspx'',window,' 'Ful lscreen = no;

Scrollbars = no;菜单栏=无; Locationbar =无;可调整大小=无;状态=否;

dialogWidth = 450px; dialogHeight = 400px;'')}


// - >< / script>< / HEAD>< body

onbeforeunload =" ; CheckIfPageHasChanged()">< form id =" Form1" method =" post"

runat =" server">& nbsp;& nbsp;& nbsp;


< input type = QUOT;隐藏" id =" txtChanged">< a

href =" javascript :PopUpMyWindow()">这是一个链接。< / a>< ; input type =" text"

onBlur =" javascript :SetPageToChanged();">< / form>< / body>< / HTML>

感谢您的帮助!

Daniel Walzenbach
Thread-Topic: How to prevent a changed page from beeing closed???
thread-index: AcPvHj7cM4M4jlZyTGCzRjdtRTekVg==
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
From: "=?Utf-8?B?RGFuaWVsIFdhbHplbmJhY2g=?=" <da**********************@freudenberg.de>Subject: How to prevent a changed page from beeing closed???
Date: Mon, 9 Feb 2004 07:06:07 -0800
Lines: 32
Message-ID: <58**********************************@microsoft.co m>
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 8bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Newsgroups: microsoft.public.dotnet.framework.aspnet
Path: cpmsftngxa07.phx.gbl
Xref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.framework.aspnet:208562
NNTP-Posting-Host: tk2msftcmty1.phx.gbl 10.40.1.180
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

Hi,
I am faced with the following problem: I have a page (leta??s call this
page page1.aspx) containing some TextBoxes and a hyperlink which opens
another page (leta??s call this page page2.aspx) as a popup using either
window.open or window.showModalDialog. Since I want to warn the users of my
application when they try to close page1.aspx and have changed the values
in the meantime I thought about using the a??onbeforeunloada?? event of the
body of page1.aspx. Unfortunately this event also fires when the link gets
clicked which is NOT intended by me.
Does anybody know how I can handle the close event of the page while being
able to open links of my page? I know that it can somehow be done since
Ia??ve seen this behaviour in MS CRM...

I tried the following:

<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="WebForm1.aspx.vb" Inherits="ATV2004.WebForm1"%><!DOCTYPE HTML
PUBLIC "-//W3C//DTD HTML 4.0
Transitional//EN"><HTML><HEAD><title>WebForm1</title><meta
name="vs_snapToGrid" content="True"><meta name="vs_showGrid"
content="True"><meta name="GENERATOR" content="Microsoft Visual Studio .NET
7.1"><meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1"><meta
name="vs_defaultClientScript" content="JavaScript"><meta
name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5"><script
language="javascript"><!--

function SetPageToChanged() {
document.Form1.txtChanged.value="1";
}
function CheckIfPageHasChanged() {
if (document.Form1.txtChanged.value == "1")
{
event.returnValue =
"\n\n-----------------------------------------------------------------------
---------------------------------------\nTo save your changes, click
Cancel, and then click Save or Save and Close.\n\nTo close this record
without saving your changes, click
OK.\n-----------------------------------------------------------------------
---------------------------------------\n";
}
}

function PopUpMyWindow(){
window.showModalDialog(''WebForm2.aspx'',window,''Ful lscreen=no;
Scrollbars=no; Menubar=no; Locationbar=no; Resizable=no; Status=no;
dialogWidth=450px; dialogHeight=400px;'')}

//--></script></HEAD><body
onbeforeunload="CheckIfPageHasChanged()"><form id="Form1" method="post"
runat="server">&nbsp;&nbsp;&nbsp;

<input type="hidden" id="txtChanged"><a
href="javascript:PopUpMyWindow()">This is a link.</a><input type="text"
onBlur="javascript:SetPageToChanged();"></form></body></HTML>
Thank you for your help!
Daniel Walzenbach






Jim,


你能不能告诉我你究竟是哪个群体?

microsoft.public.internetexplorer.ie55.programming ???


非常感谢你!


Daniel

" Jim Cheshire [MSFT]" < JA ****** @ online.microsoft.com> schrieb im Newsbeitrag

新闻:6j **************** @ cpmsftngxa07.phx.gbl ...
Jim,

would you mind telling me exactly which group you mean?
microsoft.public.internetexplorer.ie55.programming ???

Thank you a lot!

Daniel
"Jim Cheshire [MSFT]" <ja******@online.microsoft.com> schrieb im Newsbeitrag
news:6j****************@cpmsftngxa07.phx.gbl...
嗨Daniel,

您应该在Internet Explorer客户端开发组中发布此问题。他们可以帮助您编写客户端代码。

Jim Cheshire,MCSE,MCSD [MSFT]
ASP.NET
开发人员支持
ja ****** @ online.microsoft.com

这篇文章是按原样提供的没有保证,也没有赋予权利。

--------------------
Hi Daniel,

You should post this question in the Internet Explorer client development
groups. They can assist you with writing client-side code.

Jim Cheshire, MCSE, MCSD [MSFT]
ASP.NET
Developer Support
ja******@online.microsoft.com

This post is provided as-is with no warranties and confers no rights.
--------------------
主题 - 如何预防从关闭的更改页面???
线程索引:AcPvHj7cM4M4jlZyTGCzRjdtRTekVg ==
X-Tomcat-NG:microsoft.public.dotnet.framework.aspnet
来自:" =?Utf ????-8乙RGFuaWVsIFdhbHplbmJhY2g = =" < da ********************** @ freudenberg.de>
Thread-Topic: How to prevent a changed page from beeing closed???
thread-index: AcPvHj7cM4M4jlZyTGCzRjdtRTekVg==
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
From: "=?Utf-8?B?RGFuaWVsIFdhbHplbmJhY2g=?=" <da**********************@freudenberg.de>
主题:如何防止更改的页面关闭? ??
日期:2004年2月9日星期一07:06:07 -0800
行数:32
消息ID:< 58 ************ **********************@microsoft.co m>
MIME-Version:1.0
Content-Type:text / plain;
charset =" Utf-8"
Content-Transfer-Encoding:8bit
X-Newsreader:适用于Windows 2000的Microsoft CDO
Content-Class:urn:content-classes:message
重要性:正常
优先级:正常
X-MimeOLE:微软MimeOLE制作V6.00.3790.0
新闻组:microsoft.public.dotnet.framework.aspnet
路径:cpmsftngxa07.phx.gbl
外部参照:cpmsftngxa07.phx.gbl
microsoft.public.dotnet.framework.aspnet:208562NNTP-Posting-Host:tk2msftcmty1.phx.gbl 10.40.1.180
X-Tomcat-NG:microsoft.public.dotnet.framework.aspnet

你好,
Subject: How to prevent a changed page from beeing closed???
Date: Mon, 9 Feb 2004 07:06:07 -0800
Lines: 32
Message-ID: <58**********************************@microsoft.co m>
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 8bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Newsgroups: microsoft.public.dotnet.framework.aspnet
Path: cpmsftngxa07.phx.gbl
Xref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.framework.aspnet:208562NNTP-Posting-Host: tk2msftcmty1.phx.gbl 10.40.1.180
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

Hi,



我遇到了以下问题:我有一个页面( leta?Ts称之为
page page1.aspx)包含一些TextBox和一个超链接打开
另一个页面(leta?Ts称这个页面为page2.aspx)作为弹出窗口使用
window.open或window.showModalDialog。因为我想警告用户



I am faced with the following problem: I have a page (leta?Ts call this
page page1.aspx) containing some TextBoxes and a hyperlink which opens
another page (leta?Ts call this page page2.aspx) as a popup using either
window.open or window.showModalDialog. Since I want to warn the users of



当我的应用程序试图关闭page1.aspx并且在此期间更改了值
我想到了使用a?oonbeforeunloada ?? page1.aspx的主体
的事件。不幸的是,当链接被点击时,这个事件也会被触发,这不是我想要的。
是否有人知道如何处理页面的关闭事件,同时能够打开我的链接页?我知道它可以以某种方式完成,因为我已经在MS CRM中看到过这种行为......

我尝试了以下内容:

<%@页面语言=" vb" AutoEventWireup =" false"
Codebehind =" WebForm1.aspx.vb" Inherits =" ATV2004.WebForm1"%><!DOCTYPE HTML
PUBLIC" - // W3C // DTD HTML 4.0
Transitional // EN">< HTML>< HEAD> ;< title> WebForm1< / title>< meta
name =" vs_snapToGrid" content =" True">< meta name =" vs_showGrid"
content =" True">< meta name =" GENERATOR" content =" Microsoft Visual Studio
..NET 7.1">< meta name =" CODE_LANGUAGE" content =" Visual Basic .NET 7.1">< meta
name =" vs_defaultClientScript" content =" JavaScript">< meta
name =" vs_targetSchema"
content =" http://schemas.microsoft.com/intellisense/ie5">< script
language =" javascript"><! -

函数SetPageToChanged(){
document.Form1.txtChanged.value =" 1";
}

函数CheckIfPageHasChanged(){
if(document.Form1.txtChanged.value ==" 1")
{event /returnValue =

" \ n\ n -------------------------------------- --------------------------------- ----------------- ---------------------- \ n要保存更改,请单击取消,然后单击保存或保存并关闭。\ n n要关闭此记录
而不保存更改,请单击

OK.\ n ----------------------- ------------------------------------------------ - ------------------------------------- \\\
" ;;
}
}

函数PopUpMyWindow(){
window.showModalDialog('''WebForm2.aspx'',window,''Ful lscreen = no;
Scrollbars = no;菜单栏=无; Locationbar =无;可调整大小=无;状态=否;
dialogWidth = 450px; dialogHeight = 400px;'')}

// - >< / script>< / HEAD>< body
onbeforeunload =" CheckIfPageHasChanged()"> < form id =" Form1" method =" post"
runat =" server">& nbsp;& nbsp;& nbsp;

< input type =" hidden" id =" txtChanged">< a
href =" javascript :PopUpMyWindow()">这是一个链接。< / a>< input type = " text"
onBlur =" javascript :SetPageToChanged();">< / form>< / body>< / HTML>

谢谢你的帮助!
Daniel Walzenbach


my application when they try to close page1.aspx and have changed the values
in the meantime I thought about using the a?oonbeforeunloada?? event of the body of page1.aspx. Unfortunately this event also fires when the link gets
clicked which is NOT intended by me.
Does anybody know how I can handle the close event of the page while being
able to open links of my page? I know that it can somehow be done since
Ia?Tve seen this behaviour in MS CRM...

I tried the following:

<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="WebForm1.aspx.vb" Inherits="ATV2004.WebForm1"%><!DOCTYPE HTML
PUBLIC "-//W3C//DTD HTML 4.0
Transitional//EN"><HTML><HEAD><title>WebForm1</title><meta
name="vs_snapToGrid" content="True"><meta name="vs_showGrid"
content="True"><meta name="GENERATOR" content="Microsoft Visual Studio ..NET 7.1"><meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1"><meta
name="vs_defaultClientScript" content="JavaScript"><meta
name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5"><script
language="javascript"><!--

function SetPageToChanged() {
document.Form1.txtChanged.value="1";
}
function CheckIfPageHasChanged() {
if (document.Form1.txtChanged.value == "1")
{
event.returnValue =
"\n\n----------------------------------------------------------------------- ---------------------------------------\nTo save your changes, click
Cancel, and then click Save or Save and Close.\n\nTo close this record
without saving your changes, click
OK.\n----------------------------------------------------------------------- ---------------------------------------\n";
}
}

function PopUpMyWindow(){
window.showModalDialog(''WebForm2.aspx'',window,''Ful lscreen=no;
Scrollbars=no; Menubar=no; Locationbar=no; Resizable=no; Status=no;
dialogWidth=450px; dialogHeight=400px;'')}

//--></script></HEAD><body
onbeforeunload="CheckIfPageHasChanged()"><form id="Form1" method="post"
runat="server">&nbsp;&nbsp;&nbsp;

<input type="hidden" id="txtChanged"><a
href="javascript:PopUpMyWindow()">This is a link.</a><input type="text"
onBlur="javascript:SetPageToChanged();"></form></body></HTML>
Thank you for your help!
Daniel Walzenbach



你无法阻止用户以这种方式关闭页面。你唯一的

选项是使用onBeforeOnload事件来询问用户他们是否希望
留在页面上。你无法控制对话框的样子,

以及按钮的含义。

http://msdn.microsoft.com/workshop/a...foreunload.asp

-

谢谢,


Eric Lawrence

项目经理

援助和全球服务


此帖子按原样提供。没有保证,也没有授予任何权利。

Daniel Walzenbach <哒********************** @ freudenberg.de>写在

消息新闻:58 ********************************** @ microsof t.com ...
You cannot prevent the user from closing the page in this way. The only
option you have is to use the onBeforeOnload event to ask the user if they''d
like to stay on the page. You cannot control what the dialog looks like,
nor what the buttons say.

http://msdn.microsoft.com/workshop/a...foreunload.asp
--
Thanks,

Eric Lawrence
Program Manager
Assistance and Worldwide Services

This posting is provided "AS IS" with no warranties, and confers no rights.
"Daniel Walzenbach" <da**********************@freudenberg.de> wrote in
message news:58**********************************@microsof t.com...


我遇到了以下问题:我有一个页面(让我们称这个页面为
page1。 aspx)包含一些TextBoxes和一个超链接,使用window.open

或窗口打开另一个

页面(让我们称之为page2.aspx)作为弹出窗口.showModalDialog。因为我想警告我的应用程序的用户

当他们试图关闭page1.aspx并且已经更改了

中的值时我想到了使用onbeforeunload ;

page1.aspx的正文事件。不幸的是,当链接被点击时,此事件也会触发

,这不是我想要的。有没有人知道如何处理页面的关闭事件,而
能够打开我页面的链接?我知道它可以以某种方式完成,因为我已经在MS CRM中看到了这种行为......
我尝试了以下内容:

<% @ Page Language =" vb" AutoEventWireup = QUOT假QUOT;
Codebehind =" WebForm1.aspx.vb" Inherits =" ATV2004.WebForm1"%><!DOCTYPE HTML

PUBLIC" - // W3C // DTD HTML 4.0

Transitional // EN"> ;< HTML>< HEAD>< title> WebForm1< / title>< meta

name =" vs_snapToGrid" content =" True">< meta name =" vs_showGrid"

content =" True">< meta name =" GENERATOR" content =" Microsoft Visual Studio .NET

7.1">< meta name =" CODE_LANGUAGE" content =" Visual Basic .NET 7.1"< meta

name =" vs_defaultClientScript" content =" JavaScript">< meta

name =" vs_targetSchema"

content =" http://schemas.microsoft.com/intellisense/ie5" ;>< script

language =" javascript"><! -
函数SetPageToChanged(){
document.Form1.txtChanged.value =" 1" ;;
}

函数CheckIfPageHasChanged(){
if(document.Form1.txtChanged.value ==" 1")
{
event.returnValue =
" \ n \ n ---------------------------------- -------------------------------------

----- ---------------------------------- \ n要保存更改,请单击取消,

然后点击保存或保存并关闭。禁止关闭此记录

保存更改,点击

OK.\
--- -------------------------------------------------- ------------------

------------------------ --------------- \\\
英寸;函数PopUpMyWindow(){
window.showModalDialog('''WebForm2.aspx'',window,''Ful lscreen = no;
Scrollbars = no; Menubar = no; Locationbar = no; Resizable = no; Status = no;

dialogWidth = 450px; dialogHeight = 400px;'')}
// - >< / script>< / HEAD>< body
onbeforeunload =" CheckIfPageHasChanged()">< form id =" Form1" method =" post"

runat =" server">& nbsp;& nbsp;& nbsp;
< input type =" hidden" id =" txtChanged">< a
href =" javascript :PopUpMyWindow()">这是一个链接。< / a>< input type = " text"

onBlur =" javascript :SetPageToChanged();"< / form>< / body>< / HTML>

感谢您的帮助!
Daniel Walzenbach
Hi,

I am faced with the following problem: I have a page (let''s call this page page1.aspx) containing some TextBoxes and a hyperlink which opens another
page (let''s call this page page2.aspx) as a popup using either window.open
or window.showModalDialog. Since I want to warn the users of my application
when they try to close page1.aspx and have changed the values in the
meantime I thought about using the "onbeforeunload" event of the body of
page1.aspx. Unfortunately this event also fires when the link gets clicked
which is NOT intended by me. Does anybody know how I can handle the close event of the page while being able to open links of my page? I know that it can somehow be done since I''ve
seen this behaviour in MS CRM...
I tried the following:

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="ATV2004.WebForm1"%><!DOCTYPE HTML
PUBLIC "-//W3C//DTD HTML 4.0
Transitional//EN"><HTML><HEAD><title>WebForm1</title><meta
name="vs_snapToGrid" content="True"><meta name="vs_showGrid"
content="True"><meta name="GENERATOR" content="Microsoft Visual Studio .NET
7.1"><meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1"><meta
name="vs_defaultClientScript" content="JavaScript"><meta
name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5"><script
language="javascript"><!--
function SetPageToChanged() {
document.Form1.txtChanged.value="1";
}
function CheckIfPageHasChanged() {
if (document.Form1.txtChanged.value == "1")
{
event.returnValue = "\n\n-----------------------------------------------------------------------
---------------------------------------\nTo save your changes, click Cancel,
and then click Save or Save and Close.\n\nTo close this record without
saving your changes, click
OK.\n-----------------------------------------------------------------------
---------------------------------------\n"; }
}

function PopUpMyWindow(){
window.showModalDialog(''WebForm2.aspx'',window,''Ful lscreen=no; Scrollbars=no; Menubar=no; Locationbar=no; Resizable=no; Status=no;
dialogWidth=450px; dialogHeight=400px;'')}
//--></script></HEAD><body onbeforeunload="CheckIfPageHasChanged()"><form id="Form1" method="post"
runat="server">&nbsp;&nbsp;&nbsp;
<input type="hidden" id="txtChanged"><a href="javascript:PopUpMyWindow()">This is a link.</a><input type="text"
onBlur="javascript:SetPageToChanged();"></form></body></HTML>

Thank you for your help!
Daniel Walzenbach



这篇关于如何防止更改的页面关闭???的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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