showModalDialog参数问题
showModalDialog传递参数:
1、参数拼接放在url中,参数过长或带特殊字符时,容易出现问题。
2、参数放在showModalDialog属性里
<script type="text/javascript"> function test(){ //对象数组 var arr=new Array(); var obj0=new Object(); obj0.rno="2012001"; obj0.pno="201201"; obj0.dno="20120001"; arr[0]=obj0; var obj1=new Object(); obj1.rno="2012002"; obj1.pno="201202"; obj1.dno="20120002"; arr[1]=obj1; //二维数组 var arr1=new Array(); arr1[0]=["2012001","201201","20120001"]; arr1[1]=["2012002","201202","20120002"]; arr1[2]=["2012003","201203","20120003"]; var url="/Report/a.jsp"; var rtv = showModalDialog(url,arr,"dialogWidth:830px; dialogHeight:900px; status:0;help:0"); } </script>
<%@ page language="java" import="java.util.*" pageEncoding="GBK"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base target="_self" /> <base href="<%=basePath%>"> <title></title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <script type="text/javascript" src="<%=path%>//js/jquery.min.js"></script> <script type="text/javascript"> $(function(){ var arr = window.dialogArguments; $("#myDiv").append("<table>"); if(arr.length>0){ for(i=0;i<arr.length;i++){ $("#myDiv").append("<tr>"); $("#myDiv").append("<input type='hidden' name='rno' id='rno' value='"+arr[i].rno+"'>"); $("#myDiv").append("<input type='hidden' name='pno' id='pno' value='"+arr[i].pno+"'>"); $("#myDiv").append("<input type='hidden' name='dno' id='dno' value='"+arr[i].dno+"'>"); $("#myDiv").append("</tr>"); } } $("#myDiv").append("</table>"); $("#FM").submit(); }); </script> </head> <body> <dir id="main"> <form name="FM" id="FM" method="post" action="/*******.do"> <div id="myDiv"></div> </form> </dir> </body> </html>