javascrpit总结


   //==========找到父窗口的元素============//
   window.opener.document.frmMain.DOCINFO;
   //========调用父窗口中的js方法============//
  window.opener.contentAlert();




  /判断字符长度
  function CheckLength(strTemp){    
	var i,sum;    
	sum=0;    
	for(i=0;i<strTemp.length;i++)    
	{    
	  if ((strTemp.charCodeAt(i)>=0) && (strTemp.charCodeAt(i)<=255))    
	    sum=sum+1;    
	  else   
	    sum=sum+2;    
	}    
	return sum/2;    
 }    



 //判断是否都是数字
  function isNumber(oNum) { 
	  if(!oNum) 
	   return false; 
	  var strP=/^\d+(\.\d+)?$/; 
	  if(!strP.test(oNum)) return false; 
	  try{ 
	  if(parseFloat(oNum)!=oNum) return false; 
	  } 
	  catch(ex) 
	  { 
	  return false; 
	  } 
	  return true; 
  }




父窗口刷新,子窗口关闭
 window.opener.location.reload();
 window.close();



给select添加值:
 var select=document.getElementById("select1");
 select.options.add(new Option("男人","1"); 
 select.options.add(new Option("女人","2"); 
 (注:temp[0]是键,temp[1]是值)




创建Excel文档:
 
<script language="javascript">
    var ExcelSheet;
    ExcelApp = new ActiveXObject("Excel.Application");
    ExcelSheet = new ActiveXObject("Excel.Sheet");
    //本代码启动创建对象的应用程序(在这种情况下,Microsoft Excel 工作表)。
    //一旦对象被创建,就可以用定义的对象变量在代码中引用它。 
    //在下面的例子中,通过对象变量 ExcelSheet 访问新对象的属性和方法和其他 Excel 对象,
    //包括 Application 对象和 ActiveSheet.Cells 集合。 
    // 使 Excel 通过 Application 对象可见。
    ExcelSheet.Application.Visible = true;
     //文字大小
     ExcelSheet.ActiveSheet.Cells(i,j).Font.Size=9;
     //单元格格式设置为文本
     ExcelSheet.ActiveSheet.Cells(i,j).numberformatlocal="@";
    // 将一些文本放置到表格的第一格中。
    ExcelSheet.ActiveSheet.Cells(1,1).Value = "This is column A, row 1";
    // 保存表格。
    ExcelSheet.SaveAs("C:\\TEST.XLS");
    // 用 Application 对象用 Quit 方法关闭 Excel。
    ExcelSheet.Application.Quit();
</script>





                            

你可能感兴趣的:(C++,c,Microsoft,Excel,J#)