gao's profileMichealPhotosBlogLists Tools Help

gao

Micheal

November 19

javascript check string is a data formate

String.prototype.isDate   =   function()  
  {  
        var   r   =   this.match(/^(\d{4})(-|\/)(\d{2})\2(\d{2})$/);    
        if(r==null)return   false;   var   d   =   new   Date(r[1],   r[3]-1,   r[4]);    
        return(d.getFullYear()==r[1]&&(d.getMonth()+1)==r[3]&&d.getDate()==r[4]);  
  }  
August 31

learning FPA-reference

I have started to learn FPA and FPC.

Here is my study-notes,almost reference from web source.

 

August 03

webpage print with javascript

 

1.<a   href="javascript:self.focus();self.print();">打印</a>

 

2.selected from :http://www.chinaue.com/html/2006-4-20/20064201622421.htm

javascript. 打印大全  —— selected from:http://jerrie.9hy.com/contents/1155176737.phtml

(1)<script. defer>
function SetPrintSettings() {
 // -- advanced features
 factory.printing.SetMarginMeasure(2) // measure margins in inches
 factory.SetPageRange(false, 1, 3) // need pages from 1 to 3
 factory.printing.printer = "HP DeskJet 870C"
 factory.printing.copies = 2
 factory.printing.collate = true
 factory.printing.paperSize = "A4"
 factory.printing.paperSource = "Manual feed"

 // -- basic features
 factory.printing.header = "This is MeadCo"
 factory.printing.footer = "Advanced Printing by ScriptX"
 factory.printing.portrait = false
 factory.printing.leftMargin = 1.0
 factory.printing.topMargin = 1.0
 factory.printing.rightMargin = 1.0
 factory.printing.bottomMargin = 1.0
}
</script>

(2)
<script. language="javascript">
  function printsetup(){
  // 打印页面设置
  wb.execwb(8,1);
  }
  function printpreview(){
  // 打印页面预  
  wb.execwb(7,1);
  }

  function printit()
  {
  if (confirm('确定打印吗?')) {
  wb.execwb(6,6)
  }
  }
  </script>
</head>
<body>
<OBJECT classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"

height=0 id=wb name=wb width=0></OBJECT>
<input type=button name=button_print value="打印"

onclick="javascript.:printit()">
<input type=button name=button_setup value="打印页面设置"

onclick="javascript.:printsetup();">
<input type=button name=button_show value="打印预览"

onclick="javascript.:printpreview();">
<input type=button name=button_fh value="关闭"

onclick="javascript.:window.close();">

------------------------------------------------
关于这个组件还有其他的用法,列举如下:
WebBrowser.ExecWB(1,1) 打开
Web.ExecWB(2,1) 关闭现在所有的IE窗口,并打开一个新窗口
Web.ExecWB(4,1) 保存网页
Web.ExecWB(6,1) 打印
Web.ExecWB(7,1) 打印预览
Web.ExecWB(8,1) 打印页面设置
Web.ExecWB(10,1) 查看页面属性
Web.ExecWB(15,1) 好像是撤销,有待确认
Web.ExecWB(17,1) 全选
Web.ExecWB(22,1) 刷新
Web.ExecWB(45,1) 关闭窗体无提示

3.分页打印
3.1
<HTML>
<HEAD>

</HEAD>
<BODY>
<div style="page-break-after:always;"> 内容 </div>
</BODY>
</HTML>

3.2

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<style>
@media print{
INPUT {display:none}
}
</style>
</head>

<body>

<TABLE border="0" style="font-size:9pt;" width="300px" align="center">
<THEAD style="display:table-header-group;font-weight:bold">
<TR><TD colspan="2" align="center" style="font-weight:bold;border:3px double red">每页都有的表头</TD></TR>
</THEAD>
<TBODY style="text-align:center"">
<TR><TD>表格内容</TD><TD>表格内容</TD></TR>
<TR><TD>表格内容</TD><TD>表格内容</TD></TR>
<TR><TD>表格内容</TD><TD>表格内容</TD></TR>
<TR><TD>表格内容</TD><TD>表格内容</TD></TR>
<TR><TD>表格内容</TD><TD>表格内容</TD></TR>
<TR><TD>表格内容</TD><TD>表格内容</TD></TR>
<TR style="page-break-after:always;"><TD>表格内容</TD><TD>表格内容</TD></TR>
<TR><TD>表格内容</TD><TD>表格内容</TD></TR>
<TR><TD>表格内容</TD><TD>表格内容</TD></TR>
<TR><TD>表格内容</TD><TD>表格内容</TD></TR>
<TR><TD>表格内容</TD><TD>表格内容</TD></TR>
<TR><TD>表格内容</TD><TD>表格内容</TD></TR>
<TR><TD>表格内容</TD><TD>表格内容</TD></TR>
<TR style="page-break-after:always;"><TD>表格内容</TD><TD>表格内容</TD></TR>
<TR><TD>表格内容</TD><TD>表格内容</TD></TR>
<TR><TD>表格内容</TD><TD>表格内容</TD></TR>
<TR><TD>表格内容</TD><TD>表格内容</TD></TR>
<TR><TD>表格内容</TD><TD>表格内容</TD></TR>
<TR><TD>表格内容</TD><TD>表格内容</TD></TR>
<TR><TD>表格内容</TD><TD>表格内容</TD></TR>
<TR style="page-break-after:always;"><TD>表格内容</TD><TD>表格内容</TD></TR>
</TBODY>
<TFOOT style="display:table-footer-group;font-weight:bold">
<TR>
<TD colspan="2" align="center" style="font-weight:bold;border:3px double blue">每页都有的表尾</TD>
</TR>
</TFOOT>
</TABLE>
<input type=button value=" 打  印 " onclick=javascript:window.print()>
</body>
</html>

4、浮动帧打印
<SCRIPT. LANGUAGE=javascript>
function button1_onclick() {
  var doc=window.iframe1.document;
  var r=odoc.body.createTextRange();
  var stxt=r.htmlText;
  alert(stxt)
  var pwin=window.open("","print");
  pwin.document.write(stxt);
  pwin.print();
}
</SCRIPT>

July 29

get result from procedure

1.get result set from procedure begin at 2nd row
 
create or replace package PKG_HOTLINE is

type HotlineCursorType is REF CURSOR;

function getHotline return HotlineCursorType;

end;

create or replace package body PKG_HOTLINE is
function getHotline return HotlineCursorType is
hotlineCursor HotlineCursorType;
begin
open hotlineCursor for select * from hotline;
return hotlineCursor;
end;
end;
 
conn = getConnection();
stmt = conn.prepareCall(sql);
stmt.registerOutParameter(1,OracleTypes.CURSOR);
stmt.execute();
rs = ((OracleCallableStatement)stmt).getCursor(1);
while(rs.next()){
String country = rs.getString(1);
String pno = rs.getString(2);
System.out.println(“country:“+country+“|pno:”+pno);
 
2.multi result return by procedure

Multiple ResultSets at a glance

(http://www.javaworld.com/javaworld/jw-02-2000/jw-02-ssj-jdbc2.html)

The theory behind handling multiple ResultSets is very simple. The database driver handles a set of ResultSets instead of the single

ResultSet you may be used to. Thus, the logical (and simplified) structure returned by a database call of either the multiple SQL

queries scenario or the CallableStatement multiple ResultSet scenario can be thought of as a java.util.List. The elements of that

List are the ResultSets returned by the database as a response to the SQL query.

You can retrieve the current element in the results list by using the getResultSet() or getUpdateCount() method. There is no method

in the JDBC that will tell you what type of result you are currently examining (for example, a ResultSet object or updateCount int

primitive). Instead, the two getter methods return special results (null or -1) to indicate that the current result is of an unexpected

type. Both getter methods return special results when the end of the results list has been reached. You can use the getMoreResults()

method to move the current result reference forward in the list of database results. Note that the getMoreResults() method should close

any ResultSet it previously opened -- but I recommend testing the JDBC driver implementation before assuming that this is the case.

import java.sql.*;

public abstract class MultipleResultsets { // Logger helper class public static Logger log;
public static Connection setupConnection() throws Exception { // Load the database driver Class.forName(<databaseDriverClass>);
// The Logger directs output to the file "log.txt" log = new Logger("log.txt"); log.log("Time: " + new Timestamp(System.currentTimeMillis()));
// Open a connection to the database return DriverManager.getConnection(<jdbcURL>, <login>, <password>); }
public static void processStatement(PreparedStatement stmnt) throws Exception { // Execute the statement. The boolean return parameter // denotes the kind of result obtained from execution. boolean returnedResultSet = stmnt.execute(); int rsIndex = 0;
while(true) { // Did we get a ResultSet? if(! returnedResultSet ) { // This might be an update count int updateCount = stmnt.getUpdateCount();
if(updateCount == -1) { System.out.println("\nDone handling all results."); break; }
// This IS an update count log.log("Updated " + updateCount + " database rows."); } else { // This should be a ResultSet ResultSet rs = stmnt.getResultSet(); ResultSetMetaData rsmd = rs.getMetaData();
// Log ResultSet geometry here, so that we may // see the number of columns in the ResultSet log.log("Got ResultSet[" + (++rsIndex) + "]: " + rsmd.getColumnCount() + " columns.");
// Do not forget to close the ResultSet and // release the database resources owned by it! // // Since we use the getMoreResults() method to // obtain the next ResultSet or updateCount, the // explicit close is not required. However, I do // recommend closing explicitly at all times to // eliminate bad driver behavior/implementation. // // Check, for instance, the JDBC/ODBC bridge driver here.... rs.close(); }
// Get the next ResultSet returned from the Statement. // If there are no more Results, the getMoreResults method // will return false. if(!stmnt.getMoreResults()) break; } } }
http://lthu.javaeye.com/blog/147601
July 28

sth unimportent about js ,but wont be noted always

1,change td colspan ,setAttibute or td.colspan= NOTE colspan must be write like colSpan
2.get absolute offset of element .
this.offsetLeft/this.offsetTop is offset in it's parent element, u can get the true offset the element in your browser like this.
<script   language="Javascript">  
  function   getIE(e){  
  var   t=e.offsetTop  
  var   l=e.offsetLeft  
  while(e=e.offsetParent){  
  t+=e.offsetTop  
  l+=e.offsetLeft  
  }  
  alert("top="+t+"\nleft="+l)  
  }  
  </script>  
   
  <img   src="**.gif"   id=img1   onclick=getIE(this)>
 
//or
<img   id=img1   src="abc.gif"   onclick="ff(this)">  
  <script>  
  function   ff(obj){  
  obj=obj.getBoundingClientRect();  
  alert(obj.top+","+obj.left);  
  }  
  </script>
 
 
 
There are no photo albums.