zoukankan      html  css  js  c++  java
  • window.open打开新窗体并用post方式传参

    function openPostWindow(url,data,name){  //url要跳转到的页面,data要传递的数据,name显示方式(可能任意命名)
    var tempForm = document.createElement("form"); tempForm.id="tempForm1"; tempForm.method="post"; tempForm.action=url; tempForm.target=name; var hideInput = document.createElement("input"); hideInput.type="hidden"; hideInput.name= "dataname" hideInput.value= data; tempForm.appendChild(hideInput); tempForm.attachEvent("onsubmit",function(){ openWindow(name); });//必须用name不能只用url,否则无法传值到新页面 document.body.appendChild(tempForm); tempForm.fireEvent("onsubmit"); tempForm.submit(); document.body.removeChild(tempForm); } function openWindow(name) { var iWidth=1100; //弹出窗口的宽度; var iHeight=550; //弹出窗口的高度; var iTop = (window.screen.availHeight-30-iHeight)/2; //获得窗口的垂直位置; var iLeft = (window.screen.availWidth-10-iWidth)/2; //获得窗口的水平位置; window.open('about:blank',name,"height="+iHeight+", width="+iWidth+", top="+iTop+", left="+iLeft+",toolbar=no, menubar=no, scrollbars=yes,resizable=yes,location=no, status=no"); }

    在新页面中:String data = (String)request.getParameter("dataname"); //获取上个页面传入的值

    多看一行书,就少写一行代码,记录点滴,用心生活。
  • 相关阅读:
    int (*p)[10] 与*p[10]的区别
    运算顺序
    关于linux开机进入grub问题的解决方法
    对于特殊字符串的处理方法
    学习进度条
    阅读《实例化需求》4-6章有感
    学习进度条
    阅读《实例化需求》1-3章有感
    问题账户需求分析
    2016年秋季个人阅读计划
  • 原文地址:https://www.cnblogs.com/aegisada/p/4108550.html
Copyright © 2011-2022 走看看