Response.Redirect con # anchor, non funziona in IE7
-
03-07-2019 - |
Domanda
Response.Redirect(string.Format("myprofile.aspx?uid={0}&result=saved#main",user.UserID));
detto codice si traduce in
IE7 - myprofile.aspx?uid=933fdf8e-1be0-4bc2-a269-ac0b01ba4755&result=saved
FF - myprofile.aspx?uid=933fdf8e-1be0-4bc2-a269-ac0b01ba4755&result=saved#main
perché IE7 fa cadere la mia ancora?
modifica: dovrei menzionare che sto usando questo insieme al controllo della scheda dell'interfaccia utente di jQuery. Voglio che il postback si inserisca in una scheda specifica.
Soluzione
Sarebbe piuttosto un trucco, ma se IE non si comporta, potresti farlo.
passa anche un parametro, ad esempio
uid=933fdf8e-1be0-4bc2-a269-ac0b01ba4755&result=saved&hash=main#main
Quindi sulla tua pagina (prima del tag di chiusura del corpo, o come evento onload), solo per IE, estrai il parametro se presente e imposta l'hash manualmente.
<!--[if IE]>
<script>
if(document.location.href.indexOf('&hash=') != -1){
//extract value from url...
document.location.hash = extractedValue;
}
</script>
<![endif]-->
Altri suggerimenti
Forse è un problema di regressione da IE6?
Hai provato aggirarlo anteponendolo con un & amp ;?
Ho usato RegisterClientScriptBlock
per emettere window.location
.
Qualcosa del genere:
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);