Asp.net IE9-下载文件的信息栏出现在父窗口上;非当前 原职
我的Web应用程序的一个功能是打印报告。这些报告需要一个弹出窗口,允许用户优化报告的参数。这不能改变 在IE9之前,当用户单击弹出窗口上的我的“预览”按钮时,一旦呈现报告,他们将获得如下对话框: 对我的客户来说,这很简单,也很直观 但是,升级到IE9后,弹出窗口的父窗口中会显示消息栏(信息栏/下载栏),不管它叫什么: 为了下载或打开报告,用户现在需要关闭弹出窗口,然后在下载栏上选择适当的操作 这是一个相当令人沮丧的工作 我在网上寻找了一些方法,可以在弹出窗口中显示下载栏(首选),恢复到原来的对话框,或者将其全部删除 还没有解决办法。如果任何人有任何IE解决方案/解决方法,请发布它们Asp.net IE9-下载文件的信息栏出现在父窗口上;非当前 原职,asp.net,html,internet-explorer-9,Asp.net,Html,Internet Explorer 9,我的Web应用程序的一个功能是打印报告。这些报告需要一个弹出窗口,允许用户优化报告的参数。这不能改变 在IE9之前,当用户单击弹出窗口上的我的“预览”按钮时,一旦呈现报告,他们将获得如下对话框: 对我的客户来说,这很简单,也很直观 但是,升级到IE9后,弹出窗口的父窗口中会显示消息栏(信息栏/下载栏),不管它叫什么: 为了下载或打开报告,用户现在需要关闭弹出窗口,然后在下载栏上选择适当的操作 这是一个相当令人沮丧的工作 我在网上寻找了一些方法,可以在弹出窗口中显示下载栏(首选),恢复到原来的
更新 更新此更新以下步骤确实暴露了一个bug,但与我的问题无关,因为它发生在IE的所有版本上。我认为这很接近,但我需要更多地查看测试以获得准确的问题 好的,所以我更深入地研究了代码,并将其缩减到足以产生问题的程度。它实际上与我的原始版本(grrr)不同,但可能相关 您需要的:
- 视窗7
- IIS 7.0
<html>
<head>
<script type="text/javascript">
window.dialog = new Object();
var myFunc = function() { window.alert('hello')};
function test(){
window.dialog.open('DummyDialog.htm',myFunc,false);
};
window.dialog.open = function(sUrl, fpReturn, bNoResize) {
window.dialog.__returnFunction = fpReturn;
window.dialog.returnValue = null;
window.dialog.arguments = new Array();
for (var x = 2; x < arguments.length; x++) {
window.dialog.arguments[x - 2] = arguments[x];
}
window.dialog.arguments[window.dialog.arguments.length] = window;
sUrl += new Date().getTime().toString();
var sFeatures;
var nWidth = 500; var nHeight = 500; var nLeft = 100; var nTop = 100;
if (window.dialog.position) {
nLeft = window.dialog.position.left;
nTop = window.dialog.position.top;
window.dialog.position = null;
}
if (sUrl.indexOf("?") != -1) {
var pairs = sUrl.split("?")[1].split("&");
var aValue, pos;
for (var i = 0; i < pairs.length; i++) {
if (pairs[i].toUpperCase().indexOf("SIZE") == 0) {
aValue = pairs[i].split("=")[1].split(",");
if (aValue.length == 2) {
nWidth = parseInt(aValue[0]);
nHeight = parseInt(aValue[1]);
break;
} else if (aValue.length == 4) {
nWidth = parseInt(aValue[0]);
nHeight = parseInt(aValue[1]);
nLeft = parseInt(aValue[2]);
nTop = parseInt(aValue[3]);
break;
}
}
}
}
nTop -= 1;
sFeatures = "";
window.dialog.arguments._gotoURL = sUrl;
window.dialog.arguments._dialogTitle = 'my title';
window.dialog.returnValue = window.showModalDialog("DummyDialog.htm", window.dialog.arguments, sFeatures);
};
</script>
</head>
<body>
<a href="#" onclick="test();">Test Window</a>
</body>
</html>
<html>
<head>
<script type="text/javascript">
window.dialog = new Object();
var myFunc = function() { window.alert('hello')};
function test(){
window.dialog.open('DummyDialog.htm',myFunc,false);
};
window.dialog.open = function(sUrl, fpReturn, bNoResize) {
window.dialog.__returnFunction = fpReturn;
window.dialog.returnValue = null;
window.dialog.arguments = new Array();
for (var x = 2; x < arguments.length; x++) {
window.dialog.arguments[x - 2] = arguments[x];
}
if (true) {//if (is.ie) {
window.dialog.arguments[window.dialog.arguments.length] = window;
}
sUrl += new Date().getTime().toString();
// in pixels
var sFeatures;
var nWidth = 500;
var nHeight = 500;
var nLeft = 100;
var nTop = 100;
if (window.dialog.position) {
nLeft = window.dialog.position.left;
nTop = window.dialog.position.top;
window.dialog.position = null;
}
if (sUrl.indexOf("?") != -1) {
var pairs = sUrl.split("?")[1].split("&");
var aValue, pos;
for (var i = 0; i < pairs.length; i++) {
if (pairs[i].toUpperCase().indexOf("SIZE") == 0) {
aValue = pairs[i].split("=")[1].split(",");
if (aValue.length == 2) {
nWidth = parseInt(aValue[0]);
nHeight = parseInt(aValue[1]);
break;
} else if (aValue.length == 4) {
nWidth = parseInt(aValue[0]);
nHeight = parseInt(aValue[1]);
nLeft = parseInt(aValue[2]);
nTop = parseInt(aValue[3]);
break;
}
}
}
}
nTop -= 1;
sFeatures = "";
window.dialog.arguments._gotoURL = 'download.aspx?file=MyTestFile.txt';
window.dialog.arguments._dialogTitle = 'my title';//window.getTitle();
window.dialog.returnValue = window.showModalDialog('download.aspx?file=MyTestFile.txt', window.dialog.arguments, sFeatures);
};
</script>
</head>
<body>
<a href="#" onclick="test();">Test Window</a>
</body>
</html>
<%@ Page language="vb" runat="server" explicit="true" strict="true" %>
<script language="vb" runat="server">
Sub Page_Load(Sender As Object, E As EventArgs)
Dim strRequest As String = Request.QueryString("file") '-- if something was passed to the file querystring
If strRequest <> "" Then 'get absolute path of the file
Dim path As String = Server.MapPath(strRequest) 'get file object as FileInfo
Dim file As System.IO.FileInfo = New System.IO.FileInfo(path) '-- if the file exists on the server
If file.Exists Then 'set appropriate headers
Response.Clear()
Response.AddHeader("Content-Disposition", "attachment; filename=" & file.Name)
Response.AddHeader("Content-Length", file.Length.ToString())
Response.ContentType = "application/octet-stream"
Response.WriteFile(file.FullName)
Response.End 'if file does not exist
Else
Response.Write("This file does not exist.")
End If 'nothing in the URL as HTTP GET
Else
Response.Write("Please provide a file to download.")
End If
End Sub
</script>
<Root>
<Tag>Hello World</Tag>
</Root>
window.dialog=新对象();
var myFunc=function(){window.alert('hello')};
功能测试(){
window.dialog.open('DummyDialog.htm',myFunc,false);
};
window.dialog.open=函数(sUrl、fpReturn、bNoResize){
window.dialog.\uuu returnFunction=fpReturn;
window.dialog.returnValue=null;
window.dialog.arguments=新数组();
for(var x=2;x
DummyDialog.htm包含以下内容:
<html>
<head>
<script type="text/javascript">
window.dialog = new Object();
var myFunc = function() { window.alert('hello')};
function test(){
window.dialog.open('DummyDialog.htm',myFunc,false);
};
window.dialog.open = function(sUrl, fpReturn, bNoResize) {
window.dialog.__returnFunction = fpReturn;
window.dialog.returnValue = null;
window.dialog.arguments = new Array();
for (var x = 2; x < arguments.length; x++) {
window.dialog.arguments[x - 2] = arguments[x];
}
window.dialog.arguments[window.dialog.arguments.length] = window;
sUrl += new Date().getTime().toString();
var sFeatures;
var nWidth = 500; var nHeight = 500; var nLeft = 100; var nTop = 100;
if (window.dialog.position) {
nLeft = window.dialog.position.left;
nTop = window.dialog.position.top;
window.dialog.position = null;
}
if (sUrl.indexOf("?") != -1) {
var pairs = sUrl.split("?")[1].split("&");
var aValue, pos;
for (var i = 0; i < pairs.length; i++) {
if (pairs[i].toUpperCase().indexOf("SIZE") == 0) {
aValue = pairs[i].split("=")[1].split(",");
if (aValue.length == 2) {
nWidth = parseInt(aValue[0]);
nHeight = parseInt(aValue[1]);
break;
} else if (aValue.length == 4) {
nWidth = parseInt(aValue[0]);
nHeight = parseInt(aValue[1]);
nLeft = parseInt(aValue[2]);
nTop = parseInt(aValue[3]);
break;
}
}
}
}
nTop -= 1;
sFeatures = "";
window.dialog.arguments._gotoURL = sUrl;
window.dialog.arguments._dialogTitle = 'my title';
window.dialog.returnValue = window.showModalDialog("DummyDialog.htm", window.dialog.arguments, sFeatures);
};
</script>
</head>
<body>
<a href="#" onclick="test();">Test Window</a>
</body>
</html>
<html>
<head>
<script type="text/javascript">
window.dialog = new Object();
var myFunc = function() { window.alert('hello')};
function test(){
window.dialog.open('DummyDialog.htm',myFunc,false);
};
window.dialog.open = function(sUrl, fpReturn, bNoResize) {
window.dialog.__returnFunction = fpReturn;
window.dialog.returnValue = null;
window.dialog.arguments = new Array();
for (var x = 2; x < arguments.length; x++) {
window.dialog.arguments[x - 2] = arguments[x];
}
if (true) {//if (is.ie) {
window.dialog.arguments[window.dialog.arguments.length] = window;
}
sUrl += new Date().getTime().toString();
// in pixels
var sFeatures;
var nWidth = 500;
var nHeight = 500;
var nLeft = 100;
var nTop = 100;
if (window.dialog.position) {
nLeft = window.dialog.position.left;
nTop = window.dialog.position.top;
window.dialog.position = null;
}
if (sUrl.indexOf("?") != -1) {
var pairs = sUrl.split("?")[1].split("&");
var aValue, pos;
for (var i = 0; i < pairs.length; i++) {
if (pairs[i].toUpperCase().indexOf("SIZE") == 0) {
aValue = pairs[i].split("=")[1].split(",");
if (aValue.length == 2) {
nWidth = parseInt(aValue[0]);
nHeight = parseInt(aValue[1]);
break;
} else if (aValue.length == 4) {
nWidth = parseInt(aValue[0]);
nHeight = parseInt(aValue[1]);
nLeft = parseInt(aValue[2]);
nTop = parseInt(aValue[3]);
break;
}
}
}
}
nTop -= 1;
sFeatures = "";
window.dialog.arguments._gotoURL = 'download.aspx?file=MyTestFile.txt';
window.dialog.arguments._dialogTitle = 'my title';//window.getTitle();
window.dialog.returnValue = window.showModalDialog('download.aspx?file=MyTestFile.txt', window.dialog.arguments, sFeatures);
};
</script>
</head>
<body>
<a href="#" onclick="test();">Test Window</a>
</body>
</html>
<%@ Page language="vb" runat="server" explicit="true" strict="true" %>
<script language="vb" runat="server">
Sub Page_Load(Sender As Object, E As EventArgs)
Dim strRequest As String = Request.QueryString("file") '-- if something was passed to the file querystring
If strRequest <> "" Then 'get absolute path of the file
Dim path As String = Server.MapPath(strRequest) 'get file object as FileInfo
Dim file As System.IO.FileInfo = New System.IO.FileInfo(path) '-- if the file exists on the server
If file.Exists Then 'set appropriate headers
Response.Clear()
Response.AddHeader("Content-Disposition", "attachment; filename=" & file.Name)
Response.AddHeader("Content-Length", file.Length.ToString())
Response.ContentType = "application/octet-stream"
Response.WriteFile(file.FullName)
Response.End 'if file does not exist
Else
Response.Write("This file does not exist.")
End If 'nothing in the URL as HTTP GET
Else
Response.Write("Please provide a file to download.")
End If
End Sub
</script>
<Root>
<Tag>Hello World</Tag>
</Root>
window.dialog=新对象();
var myFunc=function(){window.alert('hello')};
功能测试(){
window.dialog.open('DummyDialog.htm',myFunc,false);
};
window.dialog.open=函数(sUrl、fpReturn、bNoResize){
window.dialog.\uuu returnFunction=fpReturn;
window.dialog.returnValue=null;
window.dialog.arguments=新数组();
for(var x=2;x