【问题标题】:ASP.Net - Safari alert - Are you sure you want to leave this page?ASP.Net - Safari 警报 - 您确定要离开此页面吗?
【发布时间】:2011-04-21 11:46:40
【问题描述】:

Asp.Net 应用程序 1 - 网页包含一个超链接,例如 ShowReport
ASP.Net应用2-网页下载.aspx

在应用程序 1 中,当单击 ShowReport 链接时,我打开页面 Download.aspx(托管在单独的网站中)以向用户显示保存/下载对话框:

ShowReport.href = [http://localhost:19515/Download.aspx]

在 app2 - Download.aspx 中,我有类似的内容:

            Response.ClearHeaders();  
            Response.ClearContent();  
            Response.Clear();  
            Response.ContentType = contentType.GetFriendlyName();  
            Response.AddHeader("Content-Disposition", string.Format("attachment; filename={0}", file.Name));  
            Response.AddHeader("Content-Length", file.Length.ToString());  
            Response.TransmitFile(filePath);    

但是在 Safari 中运行应用程序时,当单击 ShowReport 链接时,我收到一条警告说
'你确定要离开这个页面吗?您有未保存的更改。单击“确定”离开或单击“取消”留下'

谁能指导我如何摆脱这个警报。

谢谢!

【问题讨论】:

    标签: asp.net safari


    【解决方案1】:

    您在某处有onbeforeunload 事件处理程序,它返回此消息的一部分。先摆脱这个。

    【讨论】:

    • 感谢您的回复,有没有其他的出路,我确实在网页中包含了.js 文件中的onbehand。但问题是我最近跳入了这个巨大的项目,从事这个项目的团队成员没有再去询问:-(你能想到什么出路吗?(不想破坏代码)
    • @iniki 好的。在需要操作之前尝试从 window 对象中取消绑定 onbeforeunload(单击链接)。使用 JQuery(如果可用),您可以这样做:$(window).unbind("onbeforeunload")
    猜你喜欢
    • 2016-12-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-12
    • 2012-03-14
    • 1970-01-01
    • 2016-12-07
    相关资源
    最近更新 更多