# アンカーを使用した Response.Redirect は、IE7 では機能しません
-
03-07-2019 - |
質問
Response.Redirect(string.Format("myprofile.aspx?uid={0}&result=saved#main",user.UserID));
上記のコードは次のように変換されます
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 のタブ コントロールと組み合わせて使用していることに注意してください。ポストバックを特定のタブに移動したいと考えています。
解決
これはかなりのハックですが、IE が動作していない場合には、これを行うことができます。
パラメータも渡します。例:
uid=933fdf8e-1be0-4bc2-a269-ac0b01ba4755&result=saved&hash=main#main
次に、ページ上 (body 終了タグの前、または onload イベントとして) で、IE の場合のみ、パラメーターが存在する場合は抽出し、ハッシュを手動で設定します。
<!--[if IE]>
<script>
if(document.location.href.indexOf('&hash=') != -1){
//extract value from url...
document.location.hash = extractedValue;
}
</script>
<![endif]-->
他のヒント
もしかしたらIE6からの回帰問題なのでしょうか?
試しましたか それを回避する &? を先頭に付けることで
私が使用した 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);
所属していません StackOverflow