window.open()参数传递及获取

 

1, 最基本的弹出窗口代码
   window.open('page.html');

2, 经过设置后的弹出窗口
   window.open('page.html', 'newwindow', 'height=100, width=400, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no')   //该句写成一行代码
   参数解释:
      window.open 弹出新窗口的命令; 
  'page.html' 弹出窗口的文件名; 
  'newwindow' 弹出窗口的名字(不是文件名),非必须,可用空''代替; 
  height=100 窗口高度; 
  width=400 窗口宽度; 
  top=0 窗口距离屏幕上方的象素值; 
  left=0 窗口距离屏幕左侧的象素值; 
  toolbar=no 是否显示工具栏,yes为显示; 
  menubar,scrollbars 表示菜单栏和滚动栏。 
  resizable=no 是否允许改变窗口大小,yes为允许; 
  location=no 是否显示地址栏,yes为允许; 
  status=no 是否显示状态栏内的信息(通常是文件已经打开),yes为允许;

下面是怎么传入参数:

1、带参数打开新窗口

$window.open("/bdfence/bdfence-division/bdfence.html?vehicleId="+ id  );


2、获取参数

var afterUrl =  window.location.search.substring(1);(问号以后的字符串)

var afterEqual = afterUrl.substring(afterUrl.indexof('=')+1).toUpperCase();(等号以后的字符串,及你所要的参数)

下面是事例代码:

	<td bgcolor="#FFFFFF" align="center">
						<input type="button" value="删除" onclick="shenqingDel(<s:property value="#shenqing.id"/>)"/><!--
						<form action="<%=path %>/shenqingHuifu.action?id=${id}" method="post">
						<input   name="zt" type="text" value="请输入回复信息" /> 
						<input type="submit" value="提交"/>
						</form>
						
					-->
					
					<input type="button" value="回复" onclick="shenqingHuifu(<s:property value="#shenqing.id"/>)"/>
					</td>

js代码:

        <script language="javascript">
           function shenqingDel(id)
           {
               if(confirm('您确定删除吗?'))
               {
                   window.location.href="<%=path %>/shenqingDel.action?id="+id;
               }
           }
           
           function shenqingHuifu(id)
           {
           window.open ("<%=path %>/admin/shenqing/huifu.jsp?id="+id,"回复窗口","fullscreen=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no, copyhistory=no,width=350,height=140,left=200,top=300");
               //var strUrl = "<%=path %>/admin/shenqing/shenqingHuifu.jsp?id="+id;
             //  alert( "用户名:"+document.form1.username.value+",密码:"+document.form1.passwd.value);
               //var strUrl = "<%=path %>/shenqingHuifu.action?id="+id;
              // window.location.href=strUrl;
           }
           
        </script>

这里面是嵌套了一个另一个网页:

huifu.jsp

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
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 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">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<style type="text/css">
.text1{width:150px; height:60px}
</style>
  </head>
  
  <body>  
  <form action="<%=path %>/shenqingHuifu.action" method="post"> 
  <table >
    <tr>
      <td>请输入回复内容<input type="hidden" name="id" value="<%=request.getParameter("id") %>"></td>
      <td>  <input type="text" name="zt" class="text1"></td>
    </tr>
    <tr>
      <th><input type="submit" value="提交"/></th>
    </tr>
  </table>
</from>
  </body>
</html>

 

  • 11
    点赞
  • 69
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值