【发布时间】:2013-07-06 21:28:21
【问题描述】:
我创建了一个 ASP.Net 应用程序页面来处理打开 FileSite 链接。有一个自定义协议可以正确处理链接,即它打开文件,但是当文件启动时它给我留下一个空的浏览器页面。
我正在处理 3 个场景
- 直接指向处理页面的链接将启动文件并关闭浏览器
- 来自内网其他页面的链接将启动处理页面,打开文件并返回原始页面
- Intranet 对话框中的链接打开处理页面,启动文件,然后关闭处理页面
我的代码如下(Codebehind 是设置 FileUrl 并选择调用两者中的哪个函数)
<script type="text/javascript" language="javascript">
// Files opened directly from link
function OpenFileSiteLink() {
window.location.href = '<%= FileUrl %>';
}
// Files opened from within Intranet
function OpenFileSiteLinkReferrer(referrer, dialogOpened) {
window.open('<%= FileUrl %>');
if (dialogOpened) {
window.open('close.html', '_self');
} else {
window.location.href = referrer;
}
}
</script>
close.html文件中的代码只有以下内容
<script type="text/javascript"> window.close();</script>
这取自How can I close a browser window without receiving the "Do you want to close this window" prompt?
任何关于如何打开协议以启动应用程序而无需额外对话框的建议将不胜感激
【问题讨论】:
标签: javascript html asp.net