window.location.href以post方式传递参数的方法
想用window.location.href跳转到另外一个界面。但直接传递get方法会暴露数据。 而用ajax或表单提交,有时在执行了方法后,无法跳转到另外的页面。 下面可以实现跳转的效果,却又能够通过post传递方法隐藏数据。 有一个不足就是,在跳转到新页面后,点击“返回”返回的是个空界面,再次点击才能返回到提交界面。
<script language=javascript>
document.write("<form action=abc.action method=post name=form1 style='display:none'>");
document.write("<input type=hidden name=name value='"+username+"'");
document.write("</form>");
document.form1.submit();
</script>
的确如此,把form用标签的形式写好在html中,submit前给input赋值,就不会跳转到大白页了,非常感谢 :idea:
把这一form标记写在页面里,隐藏,submit前给input赋值。就不会出现浏览器后退到空白页面的问题,而是直接后退到跳转前的页面。
你上面的input有问题