关于window.open传值以及打开页面的一些问题
自己学习日志:
status-level.jsp页面
<input type="text" name="imagePath" id="imagePath" size="30" value="" />
<input type="button" name="" value='选择图片'
onclick="loadWin(this.form.imagePath);return false;">
<script type="text/javascript">
<!--
function loadWin(el) {
var win = window.open("statuslevels-iconpicker.jsp?element="+el.name+"&form=statusform","","menubar=no,location=no,personalbar=no,resizable=no,scrollbars=yes,width=450,height=500");
}
</script>
-->
statuslevels-iconpicker.jsp页面
<%@ page extends="fusionj.runtime.FusionJ"
import="java.io.File,
java.util.regex.Pattern,
java.util.regex.Matcher
"
contentType="text/html;charset=GBK"
errorPage="error.jsp" %>
<html>
<head>
<html:base />
<title>insert</title>
</head>
<body>
<style>
.over{
border:1px solid #9CF;
}
.out{
border:1px solid #FFF;
}
</style>
<script>
function divStyle(bool,id){
if(bool)
document.getElementById("div"+id).className="over";
else
document.getElementById("div"+id).className="out";
}
</script>
<table> <tr align="center"><td colspan="7" >请选择图片<span style="font-size:12px; color:#900" >单击选择</span></td><tr>
<%
File paths=new File("../webapps/hotkm/home/images/status");
String[] list=paths.list();
//row:控制是否显示<tr>的参数及构造div:id
int row=1;
File path=null;
for(int i=0;i<list.length;i++){
path=new File(paths.toString()+"/"+list[i]);
//过滤掉文件大小为0的文件
if(path.length()!=0){
//过滤出所有以.gif结尾的文件并将其显示到页面
Pattern pattern = Pattern.compile(".gif");
Matcher matcher = pattern.matcher(list[i]);
if(matcher.find()){
if(row%7==1){%><tr><%}%>
<td align="center">
<div id="div<%=row%>" >
<div onMouseOver="divStyle(true,<%=row%>)" onMouseOut="divStyle(false,<%=row%>)"
onClick="selectImg('<%=list[i]%>')" align="justify" style="width:50px;
height:35px !important; height:55px;
position:static; padding-top:25px !important; padding-top:15px;border:1px solid #BFD3DC;text-align:center">
<img align="middle" src="../home/images/status/<%=list[i]%>"/>
</div>
</div>
</td>
<%if(row%7==0){%></tr><%}%>
<% row++; }}
}
%>
</table>
<script>
function selectImg(imgName){
//给父级form中的页面元素element赋值
window.opener.document.<%=get("form")%>.<%=get("element")%>.value=imgName;
//关闭子窗体
setTimeout("window.close()",0);
}
</script>
</body>
</html>