textarea 行数展示

<%@page import="com.lasun.core.model.*" %>
 <%@ page contentType="text/html;charset=UTF-8" %>
 <%@ include file="/commons/taglibs.jsp" %>
 <html>
 
 <head>
  <%@ include file="/commons/meta.jsp" %>
  <title>静态化页面编辑</title>
  <script language="javascript">
  // 注意!这行代码是每个内容页必须加的内容,否则无法正确显示。
  var P = window.parent, E = P.setDialog();
  window.onload = function(){
  P.S.auto();
     //P.addBtn( 'next', '保存', next );  //创建一个下一步按钮
  //P.addBtn( 'rese', '重 置', doreset );
 
  /* function sub(){
  var filePath=document.myForm.id.value;
  var myTextWrite=document.myForm.myTextWrite.value;
  var dirName=document.myForm.dirName.value;
  var url="${ctx}/manager/CoreTemplatePage/save.do?id="+filePath+"&dirName="+dirName+"&myTextWrite="+myTextWrite;
  window.location=url;
  }
  function next(){
  var frm = E.J('#myForm',document)[0];
  var filePath=frm.id.value;
  var myTextWrite=frm.myTextWrite.value;
  var dirName=frm.dirName.value;
  var url="${ctx}/manager/CoreTemplatePage/save.do?id="+filePath+"&dirName="+dirName+"&myTextWrite="+myTextWrite;
 // url=encodeURI(url); 
 // url=encodeURI(url); 
  window.location=url;
  P.cancel();
  }
 
  function doreset() {
     var frm = E.J('#myForm',document)[0];
  frm.reset();
  } */
 
 
 
  //document.execCommand('SaveAs')
  //$(document).bind('keydown', 'Ctrl+s',function (evt){doOnToolbarClick('save');return false; });
  //function doOnToolbarClick(id) {
   //switch (id) {
  // case "save" :          //保存            
   //  你的表单.submit();
   // break;
  //}
  //document.onkeydown=dkey;
  //function dkey(){
  // if(event.ctrlKey && window.event.keyCode ==13){
  //
  // ${"form:first"}.submit();
  // }else if(event.altKey && window.event.keyCode == 83){
  //
  // ${"form:first"}.submit();
  // }
  //}
  </script>
 
 </head>
 <style type="text/css"> 
  .b1{height:20px;border:1px solid #7f9db9;line-height:20px; padding:0} 
  input.btn{height:auto; font-size:14px; font-weight:bold; color:#000} 
  #main {color:#666} 
  textarea{border:1px solid #7f9db9; font-size:14px; width:800px; height:400px; color:#000} 
  input{font-size:14px; color:#000} 
  #main h3{color:#000} 
  .grey{color:#999} 
  em{font-style:normal; color:#FF0000; font-size:12px;} 
  #msg1,#msg2,#msg3,#msg4{ display:none} 
  #ol{position:absolute; z-index:1; padding:0px; margin:0px; border:0px; background:#ecf0f5;width:23px; text-align:left; } 
  #li{background:#ecf0f5; height:400px; overflow:hidden; width:23px; border-right:0; line-height:20px; margin:0px; padding:0px; padding-left:2px; text-align:center} 
  #myTextWrite{font-family:Arial, Helvetica, sans-serif; height:400px; margin:0px; width:800px; padding:0 0 0 28px; overflow-x: hidden; line-height:20px;} 
  </style> 
  
  <script language="javascript" type="text/javascript"> 
  String.prototype.trim2 = function() {     
  return this.replace(/(^\s*)|(\s*$)/g, ""); 
  } 
  
  function F(objid){ 
  return document.getElementById(objid).value; 
  } 
  
  function G(objid){ 
  return document.getElementById(objid); 
 }   
  
  //左侧行号的标注.
  var num=""; 
  
  function isEmpty(strVal){
   if( strVal == "" )    
  return true; 
  else    
  return false; 
  } 
  
  function isBlank(testVal){       
  var regVal=/^\s*$/;     
  return (regVal.test(testVal)); 
  } 
  
  function chLen(strVal){ 
  strVal=strVal.trim2(); 
  var cArr = strVal.match(/[^\x00-\xff]/ig);     
  return strVal.length + (cArr == null ? 0 : cArr.length);    
 } 
   
  function keyUp(){ 
  var obj=G("myTextWrite"); 
  var str=obj.value;  
  str=str.replace(/\r/gi,""); 
  str=str.split("\n"); n=str.length; 
   
  //行号的处理.
  line(n); 
   
  scroll();
  } 
  
  function scroll() {
      document.getElementById('li').style.height = 410+"px";
      document.getElementById('li').style.width = 30+"px";
      document.getElementById('myTextWrite').style.height = 410+"px";
      document.getElementById('myTextWrite').style.width = 810+"px";
      
  }
  
  function line(n){ 
  var lineobj=G("li"); 
  for(var i=1;i<=n;i++){    
  if(document.all){     
  num+=i+"\r\n";    
  }else{     
  num+=i+"\n";    
 
 
  lineobj.value=num; num=""; 
 } 
  
  function autoScroll(){ 
  var nV = 0; 
  if(!document.all){    
  nV=G("myTextWrite").scrollTop;    
  G("li").scrollTop=nV;    
  setTimeout("autoScroll()",20); 
   }  
 
  if(!document.all){ 
  window.addEventListener("load",autoScroll,false); 
  }
  </script> 
 
  <body onLoad="keyUp();"><!-- onLoad="keyUp();" style="height:400px; width:800px;"> -->
  
 <%@ include file="/commons/messages.jsp" %>
 <%-- 页面整体布局 start --%>
 <div id="main">
  <%-- 页面导航位置 start --%>
  <div class="current_position">
  <div class="current_position_icon"></div>
  当前位置:
  <span class="current_position_name">${navLabel}</span>
  </div>
  <%-- 页面导航位置 end --%>
  <%-- 页面表单 start --%>
  <div id="form_content" style="display:;height:400px; width:800px;">
  当前文件目录:【  <s:property value="id"/> 】
  <form action="${ctx}/manager/CoreTemplatePage/save.do" method="post" name="myForm" id="myForm">
  <table width="100%" align="center" class="detail_table" cellspacing="0" cellpadding="0" border="0">
  <input type="hidden" id="id" name="id" value='<s:property value="id"/>'>
  <input type="hidden" id="fileName" name="fileName" value='<s:property value="fileName"/>'>
 
  <th align="center" colspan="4">&quot;</th>
  <tr>
  <td class="title">文件名:</td>
  <td><input type="text" id="dirName"  onkeydown="enter(event,this.form)" name="dirName" maxlength="100" class="input_out" value='<s:property value="dirName"/>'> &nbsp;<!-- <span >按 Ctrl + S 保存</span> --></td>
  </tr>
  <tr align="center" colspan="4">
  <td>
  </td>
  </tr>
  </table>
  <div class="form_div" align="center">
  <table>
  <tr>
  <td>
  <textarea cols="2" rows="10" id="li" disabled></textarea>
  </td>
  <td>
  <textarea id="myTextWrite" onkeyup="keyUp()" onscroll="G('li').scrollTop = this.scrollTop;" oncontextmenu="return false" onkeydown="enter(event,this.form)" name="myTextWrite" style="font-family:arial; font-size:14px; line-height:20px; height:400px; line-width:20px; width:800px; overflow:auto" >${myText }</textarea>
  </td>
  </tr>
  </table>
  </div>
  <div class="form_div" align="center">
  <lasun:button buttonType="submit" operate="submit" value="提交"  onclick="getReferenceForm(this).action='${ctx}/manager/CoreTemplatePage/save.do'"/>
  <lasun:button buttonType="button" operate="reset"  value="重置"  onclick="batchReset(document)"/>
  </div> 
  </form>
  </div>
  <div id="b" style="display:none">
     操做已完成
  </div>
  <%-- 页面表单 end --%>
 </div>
 <%-- 页面整体布局 end --%>
 <script languaga="javascript">
 
 function enter(evt,frm) {
  //document.attachEvent("onkeydown",function(){ 
  if(event.ctrlKey && event.keyCode==83){
  //alert("Ctrl+S 组合键保存.");
  /* var id=document.form.id.value;
  var dirName=document.form.dirName.value;
  var position=document.form.position.value;
  var myTextWrite=document.form.myTextWrite.value;
  var url='${ctx}/manager/CorePageBlock/update.do?id='+id+'&dirName='+dirName+'&position='+position+'&myTextWrite='+myTextWrite;
  var path=encodeURI(encodeURI(url));
  window.location=path; */
  document.myForm.submit();
  }
  //})
 }
 
 </script>
 
 </body>
 </html>
 
 <!-- File   Name: edit.jsp -->
 <!-- Action Name: CoreAreaAction.java -->
 <!-- Model  Name:   CoreArea.java -->

本文出自 “泥土的芳香” 博客,转载请与作者联系!

你可能感兴趣的:(textarea)