【发布时间】:2011-09-13 12:49:26
【问题描述】:
我不得不运行一些服务器端代码来通过 javascript 打开多个文件,效果如下:
假设 r 只是一个拥有一些数据的阅读器:
If r IsNot Nothing Then
Dim sb As New StringBuilder()
Do While r.Read()
'added below to replace \\ with http://
strURL = Replace(CType(r("AttachmentLink"), String), "\\myServer\MyFolder\MyPath", "http://MyFolder/MyPath", , , CompareMethod.Text)
'added below to replace \ with /
strURL = Replace(strURL, "\", "/")
sb.AppendLine("window.open('" & strURL & "', '_blank', 'menubar=no');")
Loop
ClientScript.RegisterStartupScript(Me.GetType(), "popup", sb.ToString(), True)
End If
这非常适合打开多个附件... 但现在我不仅需要打开它们,还需要打印它们......
所以我尝试只使用上面的内容并稍作修改:
Do While r.Read()
'added below to replace \\ with http://
strURL = Replace(CType(r("AttachmentLink"), String), "\\myServer\MyFolder\MyPath", "http://MyFolder/MyPath", , , CompareMethod.Text)
'added below to replace \ with /
strURL = Replace(strURL, "\", "/")
sb.AppendLine("var oWindow = window.open('" & strURL & "', '_blank', 'menubar=no');")
sb.AppendLine("oWindow.print();")
sb.AppendLine("oWindow.close();")
Loop
ClientScript.RegisterStartupScript(Me.GetType(), "popup", sb.ToString(), True)
这当然行不通,没有错误,但什么也没有出现。我希望打开每个窗口并从 javascript 中弹出一个打印对话框...
有什么想法吗?
【问题讨论】:
标签: javascript asp.net vbscript