2009-01-01 87 views
0
Response.Redirect(string.Format("myprofile.aspx?uid={0}&result=saved#main",user.UserID)); 

說代碼轉換爲的Response.Redirect與#錨,不能在IE7工作

IE7 - myprofile.aspx?uid=933fdf8e-1be0-4bc2-a269-ac0b01ba4755&result=saved

FF - myprofile.aspx?uid=933fdf8e-1be0-4bc2-a269-ac0b01ba4755&result=saved#main

爲什麼IE7將我的錨?

編輯:我應該提到我與jQuery UI的選項卡控件一起使用它。我想要回發標簽到特定的選項卡。

+0

您可以驗證IE7越來越真實的URL(例如從HTTP請求),但下降的哈希值? (例如你是否安裝了Fiddler2(或類似的)?) – scunliffe 2009-01-01 15:19:23

+0

scunliffe - 我已經安裝了fiddler2,但我對這個工具很新,我無法弄清楚你的問題的答案。不過,我想感謝你向我推薦這個工具 - 我曾聽說過這個工具,但是你促使我真正瞭解它並看到它的價值。 – dfasdljkhfaskldjhfasklhf 2009-01-02 11:21:33

回答

1

這將是相當黑客,但如果IE不行爲,你可以做到這一點。

也傳遞參數,例如,

uid=933fdf8e-1be0-4bc2-a269-ac0b01ba4755&result=saved&hash=main#main 

然後在網頁上(人體接近標記之前,或作爲onload事件),只爲IE,提取參數(如果存在)和手動設置的哈希。

<!--[if IE]> 
<script> 
    if(document.location.href.indexOf('&hash=') != -1){ 
    //extract value from url... 
    document.location.hash = extractedValue; 
    } 
</script> 
<![endif]--> 
+0

document.location.hash ='<%= Request [「hash」]%>'; 工作,謝謝 - 改爲上面的代碼。 如果我server.transfer這個 - 我可以隱藏網址雜亂 - 畢竟我只是回來ui更新,你知道是否有任何暗示嗎? – dfasdljkhfaskldjhfasklhf 2009-01-02 11:20:06

0

我用RegisterClientScriptBlock發出window.location

事情是這樣的:

string url = String.Format("{0}RegForm.aspx?regId={1}#A", this.CurrentFolderUrl, this.RegId); 

Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "redirectToClientPage", String.Format("window.location='{0}'", url), true);