我有一个简单的 Web 表单,代码如下:
//...
//tons of text
//...
<a name="message" />
//...
//tons of text
//...
<asp:Button ID="ButtonSend"
runat="server"
text="Send"
onclick="ButtonSend_Click" />
POST 之后,我想将用户导航到我的锚点“消息”。我有以下代码:
protected void ButtonSend_Click(object sender, EventArgs e)
{
this.ClientScript.RegisterStartupScript(this.GetType(),
"navigate",
"window.location.hash='#message';",
true);
}
这个简单的 JavaScript 在 Firefox 3.5.2 中不起作用 - 浏览器中的 url 正在更改,但页面未导航到锚点。在 IE 8 中它可以完美运行。
为什么这段 JavaScript 代码在 Firefox 中不起作用?我错过了什么吗?