当前位置:编程学习 > C#/ASP.NET >>

页面关闭事件问题

我想当我点击页面的右上角的关闭按钮时弹出对话框提示是否关闭。请高人写个例子本人不胜感激。 --------------------编程问答-------------------- 关闭页面是没有事件的啊 这是BS架构  他都关闭页面了无法跟服务器响应 怎么会有事件呢
你可以在页面的一个button里加关闭的代码(javasrcipt) 但你要响应不能 --------------------编程问答-------------------- js

body onunload="javascript:return window.confirm(\"are you sure?\")"; --------------------编程问答-------------------- onclick="javascript"return window.confirm('确定关闭吗?')" --------------------编程问答-------------------- 我不知上面的好不好用,没有试呢,真的不能解决吗?高人指典。 --------------------编程问答-------------------- body 的onunload事件,这个好用
onunload="javascript:return window.confirm(\"are you sure?\")"; --------------------编程问答-------------------- 如果我点取消窗体不关闭吗? --------------------编程问答-------------------- 我想当我点击页面的右上角的关闭按钮时弹出对话框提示是否关闭。请高人写个例子本人不胜感激。
=================
不管你点是 或 否 之后都是关闭的 --------------------编程问答-------------------- 对了,现在我看一些脚本中比如 onclick="javascript:aa()" aa()是脚本函数。其中javascript关键字有什么用啊,我不写它也好使啊。 --------------------编程问答-------------------- mark
就象工商网上银行那种,关闭浏览器它也能提示! --------------------编程问答-------------------- 高人指典啊。 --------------------编程问答-------------------- up --------------------编程问答-------------------- body 的onunload事件,这个好用
onunload="javascript:return window.confirm(\"are you sure?\")";
=============================================================
正解 --------------------编程问答-------------------- 你试了吗,我试不好用啊! 不管我点取消还是确定都是关闭窗口了。 --------------------编程问答-------------------- onunloadbefore="javascript:return window.confirm(\"are you sure?\")";
这个呢?
--------------------编程问答-------------------- onunload里面写写好了. --------------------编程问答-------------------- 不好用,这个是onbeforeunload 事件,这个页面只要刷新就提示, 我希望高人试成功再告诉我,本人一定加分。 --------------------编程问答-------------------- window.onbeforeunload=function check()  
  {   
  if(event.clientX>document.body.clientWidth&&event.clientY<0||event.altKey)   
  {   
    window.event.returnValue="are you sure?";   
  }
  }  
这个呢 --------------------编程问答-------------------- if(event.clientX>document.body.clientWidth&&event.clientY<0||event.altKey 能不能解释一下这句话啊。 --------------------编程问答-------------------- 遇到异常情况,并不会执行这个事件 --------------------编程问答-------------------- 那句判断是什么意思啊! --------------------编程问答-------------------- up
--------------------编程问答-------------------- confirm --------------------编程问答-------------------- mark --------------------编程问答-------------------- body 的onunload事件,这个好用
onunload="javascript:return window.confirm(\"are you sure?\")";
===================================
正解 --------------------编程问答-------------------- 判定鼠位置 --------------------编程问答-------------------- window.onbeforeunload = function()
        {   
            if(event.clientX>document.body.clientWidth&&event.clientY<0||event.altKey)
            {   
                window.confirm('are   you   sure?');
            }
        } --------------------编程问答-------------------- function FF_Close() {
    window.onbeforeunload = function() {
        var n = window.event.screenX - window.screenLeft;
        var b = n > document.documentElement.scrollWidth - 20;
        if (b && window.event.clientY < 0 || window.event.altKey) {
           //你要干嘛
        }
    }
} --------------------编程问答-------------------- onbeforunload(,'') --------------------编程问答-------------------- 写一个js return confirm('你确认要退出系统吗!'); --------------------编程问答--------------------

if(confirm('确认退出?'))
  //...你要执行的事件
else
  return false;
--------------------编程问答--------------------             Response.Write("<script language=javascript>if(window.confirm('是否关闭?')){document.location.href=‘关闭以后要进入的页面’;}else {document.location.href=‘当前页面’;}</script>");
--------------------编程问答--------------------
引用 7 楼 xinfan 的回复:
我想当我点击页面的右上角的关闭按钮时弹出对话框提示是否关闭。请高人写个例子本人不胜感激。
=================
不管你点是   或   否   之后都是关闭的

是的,这个onunload也不好用 --------------------编程问答-------------------- 我给你写一个ASP.NET后台代码,绝对好用
<asp:Button ID="Button1" runat="server" Text="Button" />
protected void Page_Load(object sender, EventArgs e)
        {
            this.Button1.Attributes.Add("onclick", "return window.confirm('您确实删除该选择项吗?')");
        }
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,