悬而未决的问题。

clxxj 2004-09-20 04:46:18
http://community.csdn.net/Expert/topic/3383/3383294.xml?temp=.1986048
...全文
94 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
clxxj 2004-09-20
  • 打赏
  • 举报
回复
不好意思,下午自己已解决完毕了,
主要是在框架页面中不知如何区分页面转向和当前页面超级连接列引起页面的onbeforeunload事件.

后来在服务端代码page_load中加入一个初始化哪个全局变量的script代码,解决了问题.
jamzh 2004-09-20
  • 打赏
  • 举报
回复
up
ycc2008 2004-09-20
  • 打赏
  • 举报
回复

页面刷新也是离开呀
goody9807 2004-09-20
  • 打赏
  • 举报
回复
onunload可以吗
yichuan1982 2004-09-20
  • 打赏
  • 举报
回复
哦,我上午都去看过
你主要是想干吗?
你的想法是什么?
给一点代码?
这边不行试试其它方法?
yichuan1982 2004-09-20
  • 打赏
  • 举报
回复
去看看,呵呵
roapzone 2004-09-20
  • 打赏
  • 举报
回复
Syntax

Inline HTML <ELEMENT onbeforeunload = "handler" ... > All platforms
Event property object.onbeforeunload = handler JScript only
object.onbeforeunload = GetRef("handler") Visual Basic Scripting Edition (VBScript) 5.0 or later only
Named script <SCRIPT FOR = object EVENT = onbeforeunload> Internet Explorer only

Event Information

Bubbles No
Cancels Yes
To invoke Close the current browser window.
Navigate to another location by entering a new address or selecting a Favorite.
Click the Back, Forward, Refresh, or Home button.
Click on an a that refers the browser to another Web page.
Invoke the a click method.
Invoke the document write method.
Invoke the document open method.
Invoke the document close method.
Invoke the window close method.
Invoke the window open method, providing the possible value _self for the window name.
Invoke the window navigate or NavigateAndFind method.
Invoke the location replace method.
Invoke the location reload method.
Specify a new value for the location href property.
Submit a form to the address specified in the action attribute via the input type=submit control, or invoke the form submit method.

Default action Signals that the page is about to be unloaded.

Event Object Properties

Although event handlers in the DHTML Object Model do not receive parameters directly, a handler can query an event object for data.

Show Available Properties

altKey Sets or retrieves a value that indicates the state of the ALT key.
altLeft Sets or retrieves a value that indicates the state of the left ALT key.
clientX Sets or retrieves the x-coordinate of the mouse pointer's position relative to the client area of the window, excluding window decorations and scroll bars.
clientY Sets or retrieves the y-coordinate of the mouse pointer's position relative to the client area of the window, excluding window decorations and scroll bars.
ctrlKey Sets or retrieves the state of the CTRL key.
ctrlLeft Sets or retrieves the state of the left CTRL key.
returnValue Sets or retrieves the return value from the event.
shiftKey Sets or retrieves the state of the SHIFT key.
shiftLeft Retrieves the state of the left SHIFT key.
type Sets or retrieves the event name from the event object.

Remarks

When a string is assigned to the returnValue property of window.event, a dialog box appears that gives users the option to stay on the current page and retain the string that was assigned to it. The default statement that appears in the dialog box, "Are you sure you want to navigate away from this page? ... Press OK to continue, or Cancel to stay on the current page.", cannot be removed or altered.

Example

This example uses the onbeforeunload event to ask users whether they want to remain on the current page or navigate to a new URL. When the user clicks on the hyperlink or attempts to close the browser window, the onbeforeunload event fires on the body and a dialog box appears. If the user chooses 'OK', the page navigates to the new URL (www.microsoft.com) or closes the window; if the user chooses 'Cancel', the page remains the same.

Show Example

<HTML>
<HEAD>
<SCRIPT>
function closeIt()
{
event.returnValue = "Any string value here forces a dialog box to \
appear before closing the window.";
}
</SCRIPT>
</HEAD>
<BODY onbeforeunload="closeIt()">
<a href="http://www.microsoft.com">Click here to navigate to
www.microsoft.com</a>
</BODY>
</HTML>
Show Me
Standards Information

There is no public standard that applies to this event.

roapzone 2004-09-20
  • 打赏
  • 举报
回复
看看!!!

62,041

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧