JavaScript兼容性问题
我一直在尝试找出我的一个网络应用程序中的一个奇怪的错误。以下是事件顺序:
- 用户单击网页中的链接 它会触发使用 a 的 javascript window.showModalDialog 打开一个 URL
- 该 url 是一个 asp.net 页面 使用二进制写入来显示 PDF
当我在 Firefox 中运行它时,它工作正常。当我在 IE 中运行它时,页面上没有任何显示,并且永远不会出错。
如果我直接在 FF 或 IE 中访问 asp.net 页面的 url,它就可以正常工作。是否有任何 window.showModalDialog 问题可能导致此问题?
来自 aspx 页面页面加载的代码:
Dim req As WebRequest = WebRequest.Create("...")
Dim resp As WebResponse = req.GetResponse()
Dim rdr As BinaryReader = New BinaryReader(resp.GetResponseStream())
Dim pdfByte() As Byte = rdr.ReadBytes(Convert.ToInt32(resp.ContentLength))
Response.Clear()
Response.ContentType = "application/pdf"
Response.BinaryWrite(pdfByte)
Response.Flush()
Response.End()
Javascript:
window.showModalDialog(sUrl,'',sFeatures)
我发布的 javascript 是问题发生的地方。如果您需要更多,请告诉我。
I've been trying to track down a strange bug in one of my web applications. Here is the sequence of events:
- user clicks on a link in the webpage
which fires javascript that uses a
window.showModalDialog to open a URL - this url is an asp.net page that
uses a binary write to display a PDF
When I run this in Firefox it works fine. When I run it in IE nothing displays on the page and it never errors out.
If I go directly to the url of the asp.net page in either FF or IE it works fine. Are there any window.showModalDialog issues that could be causing this?
Code from the aspx page page load:
Dim req As WebRequest = WebRequest.Create("...")
Dim resp As WebResponse = req.GetResponse()
Dim rdr As BinaryReader = New BinaryReader(resp.GetResponseStream())
Dim pdfByte() As Byte = rdr.ReadBytes(Convert.ToInt32(resp.ContentLength))
Response.Clear()
Response.ContentType = "application/pdf"
Response.BinaryWrite(pdfByte)
Response.Flush()
Response.End()
Javascript:
window.showModalDialog(sUrl,'',sFeatures)
The javascript i posted is where the problem occurs out. Let me know if you need more.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我记得在 IE 中,页面的名称可能会导致问题,我几年前曾写过http://amrelgarhytech.blogspot.com/2008/06/windowopen-invalid-argument.html
但我不确定这是否是你的问题
I remember that in IE the name of the page could cause problems, I wrote about this years ago there http://amrelgarhytech.blogspot.com/2008/06/windowopen-invalid-argument.html
But I am not sure if this is your problem
我似乎 IE、模态对话框和 PDF 存在问题:
http://technicalsol.blogspot.com/2008/06/pdf-in-modal-dialog-box.html
解决方法似乎是将 PDF 嵌入 iFrame 中。
I seems there is an issue with IE, modal dialog and PDFs:
http://technicalsol.blogspot.com/2008/06/pdf-in-modal-dialog-box.html
The work around appears to be embed the PDF in an iFrame.
我最终将
window.showModalDialog
更改为window.open
。我发现其他一些人也有这个问题,但没有真正的解决方案让它与 showModalDialog 一起工作。I ended up changing my
window.showModalDialog
to awindow.open
. I found a few others that had this problem but no real solution to get it working with showModalDialog.