如何隐藏window.open()的URL中的参数

来源:互联网 发布:网络电信诈骗嫌犯 编辑:程序博客网 时间:2024/05/16 03:48

如何隐藏window.open()的URL中的参数


我们在使用window.open()时,URL里总是显示参数,如果我们不想让参数被用户看见,该怎么办呢?
我们可以通过创建一个虚拟的form表单来解决,看代码!

    function getWriteDownDetail(poNum,orgName){        var  url = rt + "/demo/getWriteDownDetail.do";        //首先创建一个form表单          var tempForm = document.createElement("form");            tempForm.id="tempForm1";          //制定发送请求的方式为post          tempForm.method="post";           //此为window.open的url,通过表单的action来实现          tempForm.action=url;          //利用表单的target属性来绑定window.open的一些参数(如设置窗体属性的参数等)          tempForm.target="_blank";           //创建input标签,用来设置参数          var hideInput = document.createElement("input");            hideInput.type="hidden";            hideInput.name= "poNum";          hideInput.value= poNum;         var hideInput2 = document.createElement("input");          hideInput2.type = "hidden";          hideInput2.name = "orgName";        hideInput2.value = orgName;        //将input表单放到form表单里          tempForm.appendChild(hideInput);         tempForm.appendChild(hideInput2);        //将此form表单添加到页面主体body中          document.body.appendChild(tempForm);         //手动触发,提交表单          tempForm.submit();        //从body中移除form表单          document.body.removeChild(tempForm);      }
0 0
原创粉丝点击