當湯姆Gullen認爲是唯一的出路。 我假設你正在使用ASP.NET。
您可以創建一個公共函數,它接收您想在新窗口中打開的Url。 此功能然後重定向到執行髒作業的頁面。
Public Function ResponseRedirect(ByVal urlRedirect As String) As Boolean
HttpContext.Current.Response.Redirect("Redirector.aspx?goto=" & HttpUtility.UrlEncode(urlRedirect))
End Function
這是Redirector.aspx
Public Partial Class Redirector
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim OpenNewPage As String = ""
If Request.QueryString("goto") IsNot Nothing Then
Me.OpenNewPage = Request.QueryString("goto")
End If
If Request.UrlReferrer.AbsoluteUri IsNot Nothing Then
Me.Referer = Request.UrlReferrer.AbsoluteUri
End If
End Sub
Private _OpenNewPage As String = ""
Public Property OpenNewPage() As String
Get
Return _OpenNewPage
End Get
Set(ByVal value As String)
_OpenNewPage = value
End Set
End Property
Private _Referer As String = ""
Public Property Referer() As String
Get
Return _Referer
End Get
Set(ByVal value As String)
_Referer = value
End Set
End Property
End Class
和Redirector.asp
<script type="text/javascript">
window.open('<%=Me.OpenNewPage%>', '_blank', '');
window.document.location.href = '<%=Me.Referer%>';
</script>
的HTML這不是真的很優雅的代碼,但它的伎倆。 顯然,如果JavaScript被禁用,它不起作用。
我已經放在一起樣品here。
希望它有幫助。
請顯示未啓用javascript的重定向網站示例。 – Hogan 2011-05-19 11:59:47