项目中用到的JS代码

项目中用到的JS代码

function addDev()
{
 var sFeatures="dialogWidth:700px;dialogHeight:500px;scroll:no;";
 var customerId = document.all['cusId'].value;
 var result= window.showModalDialog('<%=appURL %>/businesspermit/DeviceSelectAction.do?formAction=toAddPage&customerId='+customerId,"",sFeatures);
 if(result!=null )
 {
  <logic:present name="edit" scope="request">
     document.CustomerSetForm.action="<%=appURL %>/businesspermit/CustomerSetAction.do?formAction=toEditBusi&showType=1";
  </logic:present>
   <logic:notPresent name="edit" scope="request">
   document.CustomerSetForm.action="<%=appURL %>/businesspermit/CustomerSetAction.do?formAction=getBusinessSet";
   </logic:notPresent>
  
  // window.location.reload();
  
  CustomerSetForm.submit();
 }
}

这个函数表示:添加新的设备JS函数,window.showModalDialog()会返回一个值result,如果result!=null,则刷新这个页面。
原来是用window.location.reload();刷新页面的,但是这样就不能保留之前页面上输入的数据,为了保留原来输入的数据,换成了
document.CustomerSetForm.action=“”;
CustomerSetForm.submit();
上面的语句表示:让这个页面重新指向另一个action地址,然后提交。这样,用了Struts标签后,以前四输入的数据仍然会保留到返回后的页面了。

注意:在js代码中,可能使用譬如说<logic:present>等标签。

你可能感兴趣的:(项目中用到的JS代码)