Javascript重定向工作在chrome,但不是IE

Javascript redirect works in chrome but not IE

本文关键字:IE chrome 重定向 工作 Javascript      更新时间:2023-09-26

下面的JavaScript脚本注册表工作在chrome没有任何问题。当与IE一起使用时,URL缺少/ .

例如,使用Chrome I正确地降落在//Sever-Name/Submit.aspx上在IE中,我降落在//Sever-NameSubmit.aspx

有没有人对解决这个问题有什么建议

ScriptManager.RegisterStartupScript(this, this.GetType(), "redirect",
"alert('Your request Was submitted successfully. You will be redirected to the confirmation page.');
window.location='" + Request.ApplicationPath + "Submit.aspx';", true);

应该是:

window.location='" + "/" + Request.ApplicationPath + "/" + "Submit.aspx';", true);

另外,在JavaScript中,"/"用作转义字符。您可能还必须转义转义字符:var link = "site.com//myPage.aspx"