Javascript从c#代码后面只刷新在谷歌浏览器
本文关键字:刷新 谷歌浏览器 代码 Javascript | 更新日期: 2023-09-27 18:13:10
我的网站有一个asp.net按钮,可以将值发布到外部网站,在IE和Firefox中正常工作。它会重定向到Chrome中的同一页面。
using (WebClient client = new WebClient())
{
HttpContext.Current.Response.Write(string.Format("<body onload=document.forms[0].submit();window.location='"{0}'";>", "Dashboard.aspx"));
HttpContext.Current.Response.Write(string.Format("<form name='"Form'" target=_blank method=post action='"{0}'">", URL));
HttpContext.Current.Response.Write(string.Format("<input type=hidden name='"fname'" value='"{0}'">", FirstName));
HttpContext.Current.Response.Write(string.Format("<input type=hidden name='"lname'" value='"{0}'">", LastName));
HttpContext.Current.Response.Write(string.Format("<input type=hidden name='"id'" value='"{0}'">", ID));
HttpContext.Current.Response.Write(string.Format("<input type=hidden name='"tier'" value='"{0}'">", tier));
HttpContext.Current.Response.Write(string.Format("<input type=hidden name='"promo_code'" value='"{0}'">", promoCode));
HttpContext.Current.Response.Write(string.Format("<input type=hidden name='"login_key'" value='"{0}'">", hashedKey));
HttpContext.Current.Response.Write("</form>");
HttpContext.Current.Response.Write("</body>");
}
期望的行为是打开一个新的选项卡或窗口与外部站点加载,参数通过POST传递。
当前行为是页面简单刷新。这是Chrome的已知问题吗?我的猜测是,它阻止了javascript,因为它认为它被"注入"。
我猜你在发布表单&修改url
不需要window.location.href
。提交表格就足够了。此外,您可能应该正确地引用这些属性,看看是否有帮助。