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"); //获取上个页面传入的值

    多看一行书,就少写一行代码,记录点滴,用心生活。
  • 相关阅读:
    仿照everything写的一个超级速查 原创
    [转]SharePoint 2013 Online App Development – Part 1
    [转]SharePoint 2013 App 开发 (2)
    [转]ASP.NET自定义控件复杂属性声明持久性浅析
    HasRights方法参数
    故障分析神器——BTrace
    JVM——Memory Analyzor分析内存溢出
    关于句柄
    Java内存区域与内存溢出
    命令行的使用
  • 原文地址:https://www.cnblogs.com/aegisada/p/4108550.html
Copyright © 2011-2022 走看看