哈佛大學自習室的二十條名言
1. This moment will nap, you will have a dream; But this moment study, you will interpret a dream.
此刻打盹,你將做夢;此刻學習,你將圓夢。
2. I leave uncultivated today, was precisely yesterday perishes tomorrow which person of the body implored.
我荒廢的今日,正是昨日殞身之人祈求的明日。
3. Thought is already is late, exactly is the earliest time.
覺得為時已晚的時候,恰恰是最早的時候。
4. Not matter of the today will drag tomorrow.
勿將今日之事拖到明日。
5. Time the study pain is temporary, has not learned the pain is life-long.
學習時的苦痛是暫時的,而未學到的痛苦是終身的。
6. Studies this matter, lacks the time, but is lacks diligently.
學習這件事不是缺少時間,而是缺少努力。
7. Perhaps happiness does not arrange the position, but succeeds must arrange the position.
幸福或許不排名次,而成功必排名次。
8. The study certainly is not the life complete. But, since continually life part of - studies also is unable to conquer, what but also can make?
學習並不是人生的全部。但,既然連人生的一部分——學習也無法征服,還能做什麼呢?
9. Please enjoy the pain which is unable to avoid.
請享受無法迴避的痛苦。
10. Only has compared to the others early, diligently diligently, can feel the successful taste.
只有比別人更早、更勤奮的努力,才能嘗到成功的滋味。
11. Nobody can casually succeed, it comes from the thorough self-controland the will.
沒有人能隨隨便便成功,它來自徹底的自我管理和意志。
12. The time is passing.
時間在流逝...
13. Now drips the saliva, will become tomorrow the tear.
現在淌的哈喇子,將成為明天的眼淚。
14. The dog equally study, the gentleman equally plays.
狗一樣地學,紳士一樣地玩。
15. Today does not walk, will have to run tomorrow.
今天不走,明天就不得不跑了。
16. The investment future person will be, will be loyal to the reality person.
投資未來的人是忠於現實的人。
17. The education level represents the income.
教育程度代表收入。
18. One day, has not been able again to come.
一天過完,不會再來。
19. Even if the present, the match does not stop changes the page.
即使是現在,對手也沒有停止翻書本。
20. Has not been difficult, then does not have attains
沒有艱辛,便沒有收穫。
Experience is the mother of wisdom.
經驗為成功之母
A person's heart is like a field:if no good seeds are sown,nothing good wille grow.
人的心是一畦田,土地沒有播下好種子、也長不出好果實。
要走好明天的路,必須記住昨天走過的路,思索今天正在走著的路。
2012年11月6日 星期二
2012年9月6日 星期四
2012年8月25日 星期六
Sport Rec 8-10
| Sep | |
| 9/3 | 滾筒40min |
| Aug | |
| 8/29 | 滾筒40min |
| 8/26 | 6K |
| 8/25 | 6K |
| 8/21 | 滾筒40min |
| 8/20 | 8k |
| 8/18 | 70k 蘆洲-五分山頂,菁茼上了車(怡君騎不動了) |
| 8/15 | 9K.. |
| 8/12 | 6k太熱收工.. |
| 8/11 | 2k下雷陣雨.... |
| 8/5 | 11k |
2012年8月13日 星期一
20120813滾筒16k-rpm171max
許久不見的轉速171...保持100rpm
最後4分鐘隨便踩
| 10 min | 39/19 |
| 10 min | 53/19 |
| 9 min | 53/17 |
| 1 min | 53/13 |
| 5 min | 39/17 |
| 1 min | 39/17 |
| 4 min | 39/19 |
2012年7月30日 星期一
2012下半年
。weight control now 78.6/kg
。cycle km=
-----------2010/1171.5(11171.5)<2010說要一年5000、結果只有1100>
-----------2011/2427.6(13599.1)
-----------2012/417.9(14017)<2012希望今年可以破3k><0730>
。自律
。自發
。every day reset
。work for somthing
。3月半馬(若成功 年底全馬)、富邦馬我來了
。cycle km=
-----------2010/1171.5(11171.5)<2010說要一年5000、結果只有1100>
-----------2011/2427.6(13599.1)
-----------2012/417.9(14017)<2012希望今年可以破3k><0730>
。自律
。自發
。every day reset
。work for somthing
。3月半馬(若成功 年底全馬)、富邦馬我來了
標籤:
My Feeling
2012年6月24日 星期日
2012年5月20日 星期日
Sport Rec 5-7
| July | |
| 7/29 | 10k |
| 7/28 | 觀音山一趟 |
| 7/23 | 關渡橋來回7k |
| 7/21 | 小油坑26k |
| 7/14 | 福隆來回70k |
| 7/8 | 6k腳酸痛中 |
| 7/7 | 臨時工搬家 6樓= =次數就不算了 一層12階 |
| 7/2 | 5k |
| June | |
| 6/30 | 一趟北宜 50分 |
| 6/24 | 一趟北宜 47分半 |
| 6/16 | 5k |
| 6/10 | 8k |
| 6/4 | 5k |
| May | |
| 5/11 | 4k 腹痛受不了 只有4k |
| 5/17 | 4k |
| 5/22 | 4k 今天好些嚕 |
The New Milestones
五月份為了自已的人生做了決定、換了工作、到月底前皆是交接期、6/5日開始上班、換個環境換換心情、希望有所改變。
這樣也經歷了一年九個月、說長不長、說短不短、說年資不夠也不是、出了社會大部份人都是失望的…我也不例外....
不管是生活上、工作上、每個人都想追夢、但事與願違……
此時此刻可以悠閒的喝杯咖啡、騎個車悠活過一天、真是一大快樂。
這樣也經歷了一年九個月、說長不長、說短不短、說年資不夠也不是、出了社會大部份人都是失望的…我也不例外....
不管是生活上、工作上、每個人都想追夢、但事與願違……
此時此刻可以悠閒的喝杯咖啡、騎個車悠活過一天、真是一大快樂。
2012年4月17日 星期二
callable StoreProcedure
ApplicationContext application = new ClassPathXmlApplicationContext("classpath:helloword/application.xml");
datasouce = (DataSource) application.getBean("ARDataSource");
DB_Conn = datasouce.getConnection();
// 設定 CallableStatement
cs = DB_Conn.prepareCall("{call Tn_Pg_Wunhowchien.Tn_Pc_Test(?, ?, ?,?)}");
// 設定 IN參數的 Index 及值
cs.setString(1, "test1");
// 定義 OUT 參數的 Index 與型態
cs.registerOutParameter(2, OracleTypes.CURSOR);//import oracle.jdbc.OracleTypes;
cs.registerOutParameter(3, OracleTypes.VARCHAR);
cs.registerOutParameter(4, OracleTypes.VARCHAR);
// 執行並取回 OUT 參數值
cs.execute();
System.out.println(cs.getString(3));
System.out.println(cs.getString(4)); // OUT 回傳值
ResultSet list= (ResultSet) cs.getObject(2);
if(list.next()){
System.out.println(list.getString("Area_Cde"));
System.out.println(list.getString("Phone_Nbr"));
}
資料來源:mkyong.com
標籤:
JAVA
springConnectionConfig
<!-DriverManagerDataSource建立連結是只要有連接就建一個connection,無連接池作用-->
<bean id="pkmDataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName">
<value>${pkm.jdbc.driverClassName}</value>
<!--${pkm.jdbc.driverClassName}是jdbc.properties文件 中的key-->
</property>
<property name="url">
<value>${pkm.jdbc.url}</value>
</property>
<property name="username">
<value>${pkm.jdbc.username}</value>
</property>
<property name="password">
<value>${pkm.jdbc.password}</value>
</property>
</bean>
<bean id="pkmDataSource"
class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" lazy-init="false">
<property name="driverClassName" value="${pkm.jdbc.driverClassName}"/>
<property name="url" value="${pkm.jdbc.url}"/>
<property name="username" value="${pkm.jdbc.username}"/>
<property name="password" value="${pkm.jdbc.password}"/>
<property name="initialSize" value="5"/>
<property name="maxActive" value="10"/>
<property name="maxWait" value="60000"/>
<property name="poolPreparedStatements" value="true"/>
</bean>
<bean id="DataSourceA"
class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">
<value>DS1</value>
</property>
</bean>
2012年4月16日 星期一
Weblogic domain 新建伺服器
1.console>環境>伺服器>正常新增serverName資料來源linushr的BLOG並給予不同port 2.專案所需jndi必需授權給新建的server 3.%base_domain\bin\底下新建一個cmd (1)http://localhost:7001 -->為主機ip (2)cmd內容 startManagedWebLogic.cmd testServer http://localhost:7001 4.執行新增的cmd
2012年4月14日 星期六
Sport Rec 2-4
| April | |
| 4/3 | 10k |
| 4/6 | 8k |
| 4/7 | 7k |
| 4/10 | 4k |
| 4/12 | 健身房1H |
| 4/14 | 跑北宜9K |
| 4/17 | 8K |
| 4/.. | 忘了記錄、約莫8K*N次就腹痛 |
| March | |
| 3/2 | 4k |
| 3/6 | 打籃球3h休息(伏地90、開合120) |
| 3/11 | 永安來回87k+桌球2.5h |
| 3/18 | 21k 國道馬拉松(2:21:5X) |
| 3/24 | 10K |
| February | |
| 2/11 | 跑10k 約一個小時前後~比魚肌酸痛 休息幾天 |
| 2/15 | 跑5k~比魚肌超酸痛...手按伺候 |
| 2/16 | 跑8k 今天跑起來不會太酸、跑2圈測試~ |
| 2/20 | 8k |
| 2/22 | 3.91 |
標籤:
Run
2012年4月13日 星期五
jQuery過濾器
資料來源KingKong Bruce記事
過濾器 |
說明 |
範例 |
|---|---|---|
:animated |
選擇正在執行動畫效果的元素 |
$(':animated')或.filter(":animated") |
:eq(index) |
等於索引值(索引從0開始) |
$(':eq(index)')或$('Selector').eq(index) |
:even |
選擇奇數索引值,會選擇元素1與元素3;即索引值的0,2,... |
$(':even')或.filter(':even') |
:first |
選擇第一個符合的元素 |
$(':first')或.filter(':first') |
:gt(index) |
大於索引值的對應元素;索引從0開始 |
$(':gt(index)')或$('Selector').slice(index) |
:header |
選擇所有h1,h2,h3,h4,h5,h6元素 |
$(':header')或.filter(':header') |
:last |
選擇最後一個符合的元素 |
$(':last')或.filter(':last') |
:lt(index) |
小於索引值的對應元素索引從0開始 |
$(':lt(index)')或$('Selector').slice(0,index) |
:not(Selector) |
排除selector內元素 |
$(':not(selector)') |
:odd |
選擇偶數索引值對應的元素;元素2,4,6,...;:odd會選擇元素2與元素3;即索引值的1,3,... |
$(':odd') |
| [name|="value"] | 選擇指定屬性等於字串值或以該字串為前綴的值(以字串後跟著一個連字符號"-")的元素。 這個過濾器是引入CSS規範來處理語言屬性。 |
$('[attribute|=value]') |
| [name*="value"] | 選擇指定屬性包含特定字串值,不論在字串中的位置。 | $('[attribute*=value]') |
| [name~="value"] | 選擇指定屬性包含特定字串值,字串用空格分隔。 | $('[attribute~=value]') |
| [name$="value"] | 選擇指定屬性的字串是以字串值結尾。 這個比較區分大小寫。 |
$('[attribute$=value]') |
| [name="value"] | 選擇指定屬性的字串等於字串值。 | $('[attribute=value]') |
| [name!="value"] | 選擇沒有指定屬性的元素,或指定屬性的字串不等於字串值。 | $('[attribute!=value]') |
| [name^="value"] | 選擇指定屬性的字串是以字串值開頭。 | $('[attribute^=value]') |
| [name] | 選擇所有具有指定屬性的元素,該屬性的字串可以是任何值。 | $('[attribute]') |
| [name="value"][name2="value2"] | 選擇符合所有指定屬性過濾器的元素 | $('[attribute1=value1][attribute2=value2]') |
選擇器 |
說明 |
範例 |
:button |
選擇button元素和type="button"的input元素 |
$(':button') |
:checkbox |
選擇type="checkbox"的input元素 |
$(':checkbox') |
:checked |
選擇已勾選(checkbox)或已選擇(radio)的input元素 |
$(':checked') |
:disabled |
選擇設定disabled屬性的input元素 |
$(':disabled') |
:enabled |
選擇未設定disabled屬性的input元素 |
$(':enabled') |
:focus |
選擇目前焦點所在的元素,注意,不限於input元素 |
$(':focus') |
:file |
選擇type="file"屬性的input元素 |
$(':file') |
:image |
選擇type="image"屬性的input元素 |
$(':image') |
:input |
選擇input、textarea、select、button元素 |
$(':input') |
:password |
選擇type="password"屬性的input元素 |
$(':password') |
:radio |
選擇type="radio"屬性的input元素 |
$(':radio') |
:reset |
選擇type="reset"屬性的input元素 |
$(':reset') |
| :selected |
選擇所有option元素裡被選擇項目 |
$(':selected') |
:submit |
選擇button元素與type="submit"屬性的input元素 |
$(':submit') |
:text |
選擇type="text"屬性的input元素 |
$(':text') |
標籤:
Jquery
2012年4月12日 星期四
Sturt2 ZeroConfing
資料來源struts-2-hello-world-annotation-example
ZeroConfig 的InterCeptor還是要配sturts.xml
@Namespace("/User")//nameSpace很重要 沒設好mapping不到
@ResultPath(value="/")
@Result(name="success",location="pages/login.jsp")
public class LoginAction extends ActionSupport{
@Action(value="testLogin", results={
@Result(name="success",location="pages/test.jsp")
})
public String test() {
return SUCCESS;
}
@Action(value="testLogin2", results={
@Result(name="success",location="pages/test2.jsp")
})
public String test2() {
return SUCCESS;
}
}
ZeroConfig 的InterCeptor還是要配sturts.xml
@Action(value="store", interceptorRefs=@InterceptorRef("store"))
public String store() throws Exception
{
....
}
標籤:
Sturts2
JavaScript 連Oracle 10.3
尚未使用過Jsp 連結Oracle 記錄備查
jsp需引進import="java.sql.*,oracle.jdbc.*"
ResultSet rs = null;
String oracleURL="jdbc:oracle:thin:@IP位置:PORT:SID";
String oracleUser="*****";
String oraclePWD="*****";
try {
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
}catch (SQLException e){
out.print("Driver Error");
}
try {
Connection conn = DriverManager.getConnection(oracleURL,oracleUser,oraclePWD);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
rs=stmt.executeQuery("select sysdate from dual");
while(rs.next()) {
%>
now :<%=new String(rs.getString(1)) %>
<%
}
out.print("connection Success !!!");
stmt.close();
conn.close();
}catch (SQLException ce){
System.out.print(ce);
}
jsp需引進import="java.sql.*,oracle.jdbc.*"
ResultSet rs = null;
String oracleURL="jdbc:oracle:thin:@IP位置:PORT:SID";
String oracleUser="*****";
String oraclePWD="*****";
try {
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
}catch (SQLException e){
out.print("Driver Error");
}
try {
Connection conn = DriverManager.getConnection(oracleURL,oracleUser,oraclePWD);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
rs=stmt.executeQuery("select sysdate from dual");
while(rs.next()) {
%>
now :<%=new String(rs.getString(1)) %>
<%
}
out.print("connection Success !!!");
stmt.close();
conn.close();
}catch (SQLException ce){
System.out.print(ce);
}
標籤:
JavaScript,
Oracle
2012年4月10日 星期二
Sturt2 Iterceptor
Java Inteceptor
@Override public String intercept(ActionInvocation invocation) throws Exception { java.util.Map<String,Object> session = invocation.getInvocationContext().getSession(); if(session.isEmpty()) return "session"; // session is empty/expired return invocation.invoke(); }sturs.xml 引用方式
<interceptors> <interceptor name="timeouthandle" class="com.taiwanmobile.ebg.util.SessionIterceptor" /> <interceptor-stack name="sessionExpirayStack"> <interceptor-ref name="timeouthandle" /> <interceptor-ref name="defaultStack" /> </interceptor-stack> </interceptors> <default-interceptor-ref name="sessionExpirayStack" /> <global-results> <result name="global-exception">/generalError.jsp</result> <result name="sql-exception">/SqlError.jsp</result> <result name="session">/timeoutError.jsp</result> </global-results> <global-exception-mappings> <exception-mapping result="global-exception" exception="java.lang.Exception"> </exception-mapping> <exception-mapping result="sql-exception" exception="java.sql.SQLException"> </exception-mapping> </global-exception-mappings> <action name="helloInit" method="insertInit" class="test.testAction"> <interceptor-ref name="sessionExpirayStack" /> <result name="success">/qs/EBGQS100I1.jsp</result> </action>
標籤:
Sturts2
2012年3月12日 星期一
JavaScript All*2
轉截 <a href="http://www.wretch.cc/blog/r9858788/15621623" target="_blank">+ 微笑過生活 +</a>
/檔案狀態改變
<iframe src="a.html" id="f" name="f" scrolling="no" frameborder=0 marginwidth=0 marginheight=0></iframe>
<script>
var doc=window.frames["f"].document;
function s(){
if (doc.readyState=="complete"){
document.all.f.style.height=doc.body.scrollHeight
document.all.f.style.width=doc.body.scrollWidth
}
}
doc.onreadystatechange=s
</script>
//Reload後不變的文字框
<HTML>
<HEAD>
<META NAME="save" CONTENT="history">
<STYLE>
.sHistory {behavior:url(#default#savehistory);}
</STYLE>
</HEAD>
<BODY>
<INPUT type=text id=oPersistInput>
</BODY>
</HTML>
//瀏覽剪貼板
(1)拖拽瀏覽
event.dataTransfer.setData("URL", oImage.src);
sImageURL = event.dataTransfer.getData("URL")
(2)一般瀏覽
window.clipboardData.setData("Text",oSource.innerText);
window.clipboardData.getData("Text");
//操作COOKIE
function SetCookie(sName, svalue)
{
documents.cookie = sName + "=" + escape(svalue) + "; ";
}
function GetCookie(sName)
{
var aCookie = documents.cookie.split("; ");
for (var i=0; i < aCookie.length; i++)
{
var aCrumb = aCookie.split("=");
if (sName == aCrumb[0])
return unescape(aCrumb[1]);
}
}
function DelCookie(sName)
{
documents.cookie = sName + "=" + escape(svalue) + "; expires=Fri, 31 Dec 1999 23:59:59 GMT;";
}
//setTimeout新增參數
<script>
var _st = window.setTimeout;
window.setTimeout = function(fRef, mDelay) {
if(typeof fRef == ''function''){
var argu = Array.prototype.slice.call(arguments,2);
var f = (function(){ fRef.apply(null, argu); });
return _st(f, mDelay);
}
return _st(fRef,mDelay);
}
function test(x){
alert(x);
}
window.setTimeout(test,1000,''fason'');
</script>
//自訂的apply,call
Function.prototype.apply = function (obj, argu) {
if (obj) obj.constructor.prototype._caller = this;
var argus = new Array();
for (var i=0;i<argu.length;i++)
argus = "argu[" + i + "]";
var r;
eval("r = " + (obj ? ("obj._caller(" + argus.join(",") + ");") : ("this(" + argus.join(",") + ");")));
return r;
};
Function.prototype.call = function (obj) {
var argu = new Array();
for (var i=1;i<arguments.length;i++)
argu[i-1] = arguments;
return this.apply(obj, argu);
};
//下載檔案
function DownURL(strRemoteURL,strLocalURL)
{
try
{
var xmlHTTP=new ActiveXObject("Microsoft.XMLHTTP");
xmlHTTP.open("Get",strRemoteURL,false);
xmlHTTP.send();
var adodbStream=new ActiveXObject("ADODB.Stream");
adodbStream.Type=1;//1=adTypeBinary
adodbStream.Open();
adodbStream.write(xmlHTTP.responseBody);
adodbStream.SaveToFile(strLocalURL,2);
adodbStream.Close();
adodbStream=null;
xmlHTTP=null;
}
catch(e)
{
window.confirm("下載URL出錯!");
}
//window.confirm("下載完成.");
}
//檢驗連結是否有效
function getXML(URL)
{
var xmlhttp = new ActiveXObject("microsoft.xmlhttp");
xmlhttp.Open("GET",URL, false);
try
{
xmlhttp.Send();
}
catch(e){}
finally
{
var result = xmlhttp.responseText;
if(result)
{
if(xmlhttp.Status==200)
{
return(true);
}
else
{
return(false);
}
}
else
{
return(false);
}
}
}
//POST代替FORM
<SCRIPT language="VBScript">
Function URLEncoding(vstrIn)
strReturn = ""
For i = 1 To Len(vstrIn)
ThisChr = Mid(vStrIn,i,1)
If Abs(Asc(ThisChr)) < &HFF Then
strReturn = strReturn & ThisChr
Else
innerCode = Asc(ThisChr)
If innerCode < 0 Then
innerCode = innerCode + &H10000
End If
Hight8 = (innerCode And &HFF00)\ &HFF
Low8 = innerCode And &HFF
strReturn = strReturn & "%" & Hex(Hight8) & "%" & Hex(Low8)
End If
Next
URLEncoding = strReturn
End Function
Function bytes2BSTR(vIn)
strReturn = ""
For i = 1 To LenB(vIn)
ThisCharCode = AscB(MidB(vIn,i,1))
If ThisCharCode < &H80 Then
strReturn = strReturn & Chr(ThisCharCode)
Else
NextCharCode = AscB(MidB(vIn,i+1,1))
strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode))
i = i + 1
End If
Next
bytes2BSTR = strReturn
End Function
dim strA,oReq
strA = URLEncoding("submit1=Submit&text1=中文")
set oReq = CreateObject("MSXML2.XMLHTTP")
oReq.open "POST","http://ServerName/VDir/TstResult.asp",false
oReq.setRequestHeader "Content-Length",Len(strA)
oReq.setRequestHeader "CONTENT-TYPE","application/x-www-form-urlencoded"
oReq.send strA
msgbox bytes2BSTR(oReq.responseBody)
</SCRIPT>
//readyState是xmlhttp返回資料的進度,0=載入中,1=未初始化,2=已載入,3=運行中,4=完成
//組件是否安裝
isComponentInstalled("{6B053A4B-A7EC-4D3D-4567-B8FF8A1A5739}", "componentID"))
//檢查網頁是否存在
function CheckURL(URL)
{
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.Open("GET",URL, false);
try
{
xmlhttp.Send();
var result = xmlhttp.status;
}
catch(e) {return(false); }
if(result==200)
{
return true;
}
xmlhttp = null;
return false;
}
//連結資料庫
<script language="javascript">
//用 javascript 寫伺服器端連結資料庫的程式碼示例
var conn = new ActiveXObject("ADODB.Connection");
conn.Open("Provider=SQLOLEDB.1; Data Source=localhost; User ID=sa; "
+"Password=; Initial Catalog=pubs");
var rs = new ActiveXObject("ADODB.Recordset");
var sql="select * from authors";
rs.open(sql, conn);
shtml = "<table width=''100%'' border=1>";
shtml +="<tr bgcolor=''#f4f4f4''><td>au_id</td><td>au_lname</td><td>au_fname</td><td>phone</td><td>address</td><td> city</td><td>state</td><td>zip</td></tr>";
while(!rs.EOF)
{
shtml += "<tr><td>" + rs("au_id") + "</td><td>" + rs("au_lname") + "</td><td>" + rs("au_fname") + "</td><td>" + rs("phone") + "</td><td>" + rs("address") + "</td><td>" + rs("city") + "</td><td>" + rs("state") + "</td><td>" + rs("zip") + "</td></tr>";
rs.moveNext;
}
shtml += "</table>";
documents.write(shtml);
rs.close();
rs = null;
conn.close();
conn = null;
</script>
//使用資料島
<html>
<body>
srno:<input type=text datasrc=#xmldate DataFLD=srno size="76"><BR>
times:<input type=text datasrc=#xmldate DataFLD=times size="76"><BR>
<input id="first" TYPE=button value="<< 第一條記錄" onclick="xmldate.recordset.moveFirst()">
<input id="prev" TYPE=button value="<上一條記錄" onclick="xmldate.recordset.movePrevious()">
<input id="next" TYPE=button value="下一條記錄>" onclick="xmldate.recordset.moveNext()">
<input id="last" TYPE=button value="最後一條記錄>>" onclick="xmldate.recordset.moveLast()">
<input id="Add" TYPE=button value="增加新記錄" onclick="xmldate.recordset.addNew()">
<XML ID="xmldate">
<infolist>
<info ><srno>20041025-01</srno><times>null</times></info>
<info ><srno>20041101-09</srno><times>2004年10月1日2點22分0秒</times></info>
</infolist>
</XML>
</body>
</html>
//獲得參數
<body>
<a href="java script:location.href=location.href + ''?a=1&b=2''">search</a>
<script language="javascript">
<!--
var a = location.search.substr(1);
if(a.length>0)
{
var re = /([^&]*?)\=([^&]*)/g
var s = a.match(re);
for(var i= 0;i<s.length;i++)
{
alert(s);
alert(s.split("=")[1]);
}
}
//-->
</script>
</body>
//可編輯SELECT
<input type=text name=re_name style="width:100px;height:21px;font-size:10pt;"><span style="width:18px;border:0px solid red;"><select name="r00" style="margin-left:-100px;width:118px; background-color:#FFEEEE;" onChange="document.all.re_name.value=this.value;">
<option value="1">11111111<option>
<option value="2">222222</option>
<option value="3">333333</option>
</select>
</span>
//設定光標位置
function getCaret(textbox)
{
var control = document.activeElement;
textbox.focus();
var rang = document.selection.createRange();
rang.setEndPoint("StartToStart",textbox.createTextRange())
control.focus();
return rang.text.length;
}
function setCaret(textbox,pos)
{
try
{
var r =textbox.createTextRange();
r.moveStart(''character'',pos);
r.collapse(true);
r.select();
}
catch(e)
{}
}
function selectLength(textbox,start,len)
{
try
{
var r =textbox.createTextRange();
r.moveEnd(''character'',len-(textbox.value.length-start));
r.moveStart(''character'',start);
r.select();
}
catch(e)
{//alert(e.description)}
}
function insertAtCaret(textbox,text)
{
textbox.focus();
document.selection.createRange().text = text;
}
//頁內搜尋
function findInPage(str)
{
var txt, i, found,n = 0;
if (str == "")
{
return false;
}
txt = document.body.createTextRange();
for (i = 0; i <= n && (found = txt.findText(str)) != false; i++)
{
txt.moveStart("character", 1);
txt.moveEnd("textedit");
}
if (found)
{
txt.moveStart("character", -1);
txt.findText(str);
txt.select();
txt.scrollIntoView();
n++;
}
else
{
if (n > 0)
{
n = 0;
findInPage(str);
}
else
{
alert(str + "... 您要找的文字不存在。\n \n請試著輸入頁面中的關鍵字再次搜尋!");
}
}
return false;
}
//書
www.itpub.net/attachment.php?s=&postid=1894598
www.wrclub.net/down/listdown.aspx?id=1341
//操作EXECL
<script language="javascript">
function jStartExcel() {
var xls = new ActiveXObject ( "Excel.Application" );
xls.visible = true;
var newBook = xls.Workbooks.Add;
newBook.Worksheets.Add;
newBook.Worksheets(1).Activate;
xls.ActiveWorkBook.ActiveSheet.PageSetup.Orientation = 2;
xls.ActiveWorkBook.ActiveSheet.PageSetup.PaperSize = 5;
newBook.Worksheets(1).Columns("A").columnwidth=50;
newBook.Worksheets(1).Columns("A").WrapText = true;
newBook.Worksheets(1).Columns("B").columnwidth=50;
newBook.Worksheets(1).Columns("B").WrapText = true;
newBook.Worksheets(1).Range("A1:B1000").NumberFormat = "0";
newBook.Worksheets(1).Range("A1:B1000").HorizontalAlignment = -4131;
newBook.Worksheets(1).Cells(1,1).Interior.ColorIndex="15";
newBook.Worksheets(1).Cells(1,1).value="First Column, First Cell";
newBook.Worksheets(1).Cells(2,1).value="First Column, Second Cell";
newBook.Worksheets(1).Cells(1,2).value="Second Column, First Cell";
newBook.Worksheets(1).Cells(2,2).value="Second Column, Second Cell";
newBook.Worksheets(1).Name="My First WorkSheet";
}
</script>
//自訂提示條
<a href="#" title="這是提示">tip</a>
<script Language="javascript">
//***********預設設定定義.*********************
tPopWait=50;//停留tWait豪秒後顯示提示。
tPopShow=5000;//顯示tShow豪秒後關閉提示
showPopStep=20;
popOpacity=99;
//***************內部變數定義*****************
sPop=null;
curShow=null;
tFadeOut=null;
tFadeIn=null;
tFadeWaiting=null;
documents.write("<style type=''text/css''id=''defaultPopStyle''>");
documents.write(".cPopText { background-color: #F8F8F5;color:#000000; border: 1px #000000 solid;font-color: font-size: 12px; padding-right: 4px; padding-left: 4px; height: 20px; padding-top: 2px; padding-bottom: 2px; filter: Alpha(Opacity=0)}");
documents.write("</style>");
documents.write("<div id=''dypopLayer'' style=''position:absolute;z-index:1000;'' class=''cPopText''></div>");
function showPopupText(){
var o=event.srcElement;
MouseX=event.x;
MouseY=event.y;
if(o.alt!=null && o.alt!=""){o.dypop=o.alt;o.alt=""};
if(o.title!=null && o.title!=""){o.dypop=o.title;o.title=""};
if(o.dypop!=sPop) {
sPop=o.dypop;
clearTimeout(curShow);
clearTimeout(tFadeOut);
clearTimeout(tFadeIn);
clearTimeout(tFadeWaiting);
if(sPop==null || sPop=="") {
dypopLayer.innerHTML="";
dypopLayer.style.filter="Alpha()";
dypopLayer.filters.Alpha.opacity=0;
}
else {
if(o.dyclass!=null) popStyle=o.dyclass
else popStyle="cPopText";
curShow=setTimeout("showIt()",tPopWait);
}
}
}
function showIt(){
dypopLayer.className=popStyle;
dypopLayer.innerHTML=sPop;
popWidth=dypopLayer.clientWidth;
popHeight=dypopLayer.clientHeight;
if(MouseX+12+popWidth>document.body.clientWidth) popLeftAdjust=-popWidth-24
else popLeftAdjust=0;
if(MouseY+12+popHeight>document.body.clientHeight) popTopAdjust=-popHeight-24
else popTopAdjust=0;
dypopLayer.style.left=MouseX+12+document.body.scrollLeft+popLeftAdjust;
dypopLayer.style.top=MouseY+12+document.body.scrollTop+popTopAdjust;
dypopLayer.style.filter="Alpha(Opacity=0)";
fadeOut();
}
function fadeOut(){
if(dypopLayer.filters.Alpha.opacity<popOpacity) {
dypopLayer.filters.Alpha.opacity+=showPopStep;
tFadeOut=setTimeout("fadeOut()",1);
}
else {
dypopLayer.filters.Alpha.opacity=popOpacity;
tFadeWaiting=setTimeout("fadeIn()",tPopShow);
}
}
function fadeIn(){
if(dypopLayer.filters.Alpha.opacity>0) {
dypopLayer.filters.Alpha.opacity-=1;
tFadeIn=setTimeout("fadeIn()",1);
}
}
document.onmouseover=showPopupText;
</script>
//插入文字
document.onclick =function(){
var oSource = window.event.srcElement;
if(oSource.tagName!="DIV")
return false;
var sel = document.selection;
if (sel!=null) {
var rng = sel.createRange();
if (rng!=null)
rng.pasteHTML("<font color=red>插入文字</font>");
}
}
//netscapte下操作xml
doc = new ActiveXObject("Msxml2.DOMDocument");
doc = new ActiveXObject("Microsoft.XMLDOM")
->>
doc = (new DOMParser()).parseFromString(sXML,''text/xml'')
//判斷鍵值
<html>
<meta http-equiv="Content-Type" content="text/html; charset=big5">
<head>
<script language="javascript">
var ie =navigator.appName=="Microsoft Internet Explorer"?true:false;
function keyDown(e)
{
if(!ie)
{
var nkey=e.which;
var iekey=''現在是ns瀏覽器'';
var realkey=String.fromCharCode(e.which);
}
if(ie)
{
var iekey=event.keyCode;
var nkey=''現在是ie瀏覽器'';
var realkey=String.fromCharCode(event.keyCode);
if(event.keyCode==32){realkey=''\'' 空格\''''}
if(event.keyCode==13){realkey=''\'' 回車\''''}
if(event.keyCode==27){realkey=''\'' Esc\''''}
if(event.keyCode==16){realkey=''\'' Shift\''''}
if(event.keyCode==17){realkey=''\'' Ctrl\''''}
if(event.keyCode==18){realkey=''\'' Alt\''''}
}
alert(''ns瀏覽器中鍵值:''+nkey+''\n''+''ie瀏覽器中鍵值:''+iekey+''\n''+''實際鍵為''+realkey);
}
document.onkeydown = keyDown;
</script>
</head>
<body>
//javascript Document.
<hr>
<center>
<h3>請按任意一個鍵。。。。</h3>
</center>
</body>
</html>
//禁止FSO
1.註銷組件
regsvr32 /u scrrun.dll
2.修改PROGID
HKEY_CLASSES_ROOT\Scripting.FileSystemObject
Scripting.FileSystemObject
3.對於使用object的使用者,修改HKEY_CLASSES_ROOT\Scripting.
//省略號
<DIV STYLE="width: 120px; height: 50px; border: 1px solid blue;
overflow: hidden; text-overflow:ellipsis">
<NOBR>就是比如有一行文字,很長,表格內一行顯示不下.</NOBR>
</DIV>
//檢測media play版本
<IE:clientCaps ID="oClientCaps" style="{behavior:url(#default#clientcaps)}" />
<SCRIPT>
var flash="";
WMPVersion= oClientCaps.getComponentVersion("{22D6F312-B0F6-11D0-94AB-0080C74C7E95}","ComponentID");
if (WMPVersion != "") {
flash = "";
var version = WMPVersion.split(",");
var i;
for (i = 0; i < version.length; i++) {
if (i != 0)
flash += ".";
flash += version;
}
documents.write("您的Windows Media Player 版本是:"+flash+"<p>");
}
</SCRIPT>
//圖像按比例
<script language="javascript">
<!--
//圖片按比例縮放
var flag=false;
function DrawImage(ImgD){
var image=new Image();
var iwidth = 80; //定義允許圖片寬度
var iheight = 80; //定義允許圖片高度
image.src=ImgD.src;
if(image.width>0 && image.height>0){
flag=true;
if(image.width/image.height>= iwidth/iheight){
if(image.width>iwidth){
ImgD.width=iwidth;
ImgD.height=(image.height*iwidth)/image.width;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
ImgD.alt=image.width+"×"+image.height;
}
else{
if(image.height>iheight){
ImgD.height=iheight;
ImgD.width=(image.width*iheight)/image.height;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
ImgD.alt=image.width+"×"+image.height;
}
}
}
//-->
</script>
<img src=".." onload = "DrawImage(this)">
//細線SELECT
<span style="border:1px solid #000000; position:absolute; overflow:hidden;" >
<select style="margin:-2px;">
<option>1111</option>
<option>11111111111111</option>
<option>111111111</option>
</select></span>
/檔案狀態改變
<iframe src="a.html" id="f" name="f" scrolling="no" frameborder=0 marginwidth=0 marginheight=0></iframe>
<script>
var doc=window.frames["f"].document;
function s(){
if (doc.readyState=="complete"){
document.all.f.style.height=doc.body.scrollHeight
document.all.f.style.width=doc.body.scrollWidth
}
}
doc.onreadystatechange=s
</script>
//Reload後不變的文字框
<HTML>
<HEAD>
<META NAME="save" CONTENT="history">
<STYLE>
.sHistory {behavior:url(#default#savehistory);}
</STYLE>
</HEAD>
<BODY>
<INPUT type=text id=oPersistInput>
</BODY>
</HTML>
//瀏覽剪貼板
(1)拖拽瀏覽
event.dataTransfer.setData("URL", oImage.src);
sImageURL = event.dataTransfer.getData("URL")
(2)一般瀏覽
window.clipboardData.setData("Text",oSource.innerText);
window.clipboardData.getData("Text");
//操作COOKIE
function SetCookie(sName, svalue)
{
documents.cookie = sName + "=" + escape(svalue) + "; ";
}
function GetCookie(sName)
{
var aCookie = documents.cookie.split("; ");
for (var i=0; i < aCookie.length; i++)
{
var aCrumb = aCookie.split("=");
if (sName == aCrumb[0])
return unescape(aCrumb[1]);
}
}
function DelCookie(sName)
{
documents.cookie = sName + "=" + escape(svalue) + "; expires=Fri, 31 Dec 1999 23:59:59 GMT;";
}
//setTimeout新增參數
<script>
var _st = window.setTimeout;
window.setTimeout = function(fRef, mDelay) {
if(typeof fRef == ''function''){
var argu = Array.prototype.slice.call(arguments,2);
var f = (function(){ fRef.apply(null, argu); });
return _st(f, mDelay);
}
return _st(fRef,mDelay);
}
function test(x){
alert(x);
}
window.setTimeout(test,1000,''fason'');
</script>
//自訂的apply,call
Function.prototype.apply = function (obj, argu) {
if (obj) obj.constructor.prototype._caller = this;
var argus = new Array();
for (var i=0;i<argu.length;i++)
argus = "argu[" + i + "]";
var r;
eval("r = " + (obj ? ("obj._caller(" + argus.join(",") + ");") : ("this(" + argus.join(",") + ");")));
return r;
};
Function.prototype.call = function (obj) {
var argu = new Array();
for (var i=1;i<arguments.length;i++)
argu[i-1] = arguments;
return this.apply(obj, argu);
};
//下載檔案
function DownURL(strRemoteURL,strLocalURL)
{
try
{
var xmlHTTP=new ActiveXObject("Microsoft.XMLHTTP");
xmlHTTP.open("Get",strRemoteURL,false);
xmlHTTP.send();
var adodbStream=new ActiveXObject("ADODB.Stream");
adodbStream.Type=1;//1=adTypeBinary
adodbStream.Open();
adodbStream.write(xmlHTTP.responseBody);
adodbStream.SaveToFile(strLocalURL,2);
adodbStream.Close();
adodbStream=null;
xmlHTTP=null;
}
catch(e)
{
window.confirm("下載URL出錯!");
}
//window.confirm("下載完成.");
}
//檢驗連結是否有效
function getXML(URL)
{
var xmlhttp = new ActiveXObject("microsoft.xmlhttp");
xmlhttp.Open("GET",URL, false);
try
{
xmlhttp.Send();
}
catch(e){}
finally
{
var result = xmlhttp.responseText;
if(result)
{
if(xmlhttp.Status==200)
{
return(true);
}
else
{
return(false);
}
}
else
{
return(false);
}
}
}
//POST代替FORM
<SCRIPT language="VBScript">
Function URLEncoding(vstrIn)
strReturn = ""
For i = 1 To Len(vstrIn)
ThisChr = Mid(vStrIn,i,1)
If Abs(Asc(ThisChr)) < &HFF Then
strReturn = strReturn & ThisChr
Else
innerCode = Asc(ThisChr)
If innerCode < 0 Then
innerCode = innerCode + &H10000
End If
Hight8 = (innerCode And &HFF00)\ &HFF
Low8 = innerCode And &HFF
strReturn = strReturn & "%" & Hex(Hight8) & "%" & Hex(Low8)
End If
Next
URLEncoding = strReturn
End Function
Function bytes2BSTR(vIn)
strReturn = ""
For i = 1 To LenB(vIn)
ThisCharCode = AscB(MidB(vIn,i,1))
If ThisCharCode < &H80 Then
strReturn = strReturn & Chr(ThisCharCode)
Else
NextCharCode = AscB(MidB(vIn,i+1,1))
strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode))
i = i + 1
End If
Next
bytes2BSTR = strReturn
End Function
dim strA,oReq
strA = URLEncoding("submit1=Submit&text1=中文")
set oReq = CreateObject("MSXML2.XMLHTTP")
oReq.open "POST","http://ServerName/VDir/TstResult.asp",false
oReq.setRequestHeader "Content-Length",Len(strA)
oReq.setRequestHeader "CONTENT-TYPE","application/x-www-form-urlencoded"
oReq.send strA
msgbox bytes2BSTR(oReq.responseBody)
</SCRIPT>
//readyState是xmlhttp返回資料的進度,0=載入中,1=未初始化,2=已載入,3=運行中,4=完成
//組件是否安裝
isComponentInstalled("{6B053A4B-A7EC-4D3D-4567-B8FF8A1A5739}", "componentID"))
//檢查網頁是否存在
function CheckURL(URL)
{
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.Open("GET",URL, false);
try
{
xmlhttp.Send();
var result = xmlhttp.status;
}
catch(e) {return(false); }
if(result==200)
{
return true;
}
xmlhttp = null;
return false;
}
//連結資料庫
<script language="javascript">
//用 javascript 寫伺服器端連結資料庫的程式碼示例
var conn = new ActiveXObject("ADODB.Connection");
conn.Open("Provider=SQLOLEDB.1; Data Source=localhost; User ID=sa; "
+"Password=; Initial Catalog=pubs");
var rs = new ActiveXObject("ADODB.Recordset");
var sql="select * from authors";
rs.open(sql, conn);
shtml = "<table width=''100%'' border=1>";
shtml +="<tr bgcolor=''#f4f4f4''><td>au_id</td><td>au_lname</td><td>au_fname</td><td>phone</td><td>address</td><td> city</td><td>state</td><td>zip</td></tr>";
while(!rs.EOF)
{
shtml += "<tr><td>" + rs("au_id") + "</td><td>" + rs("au_lname") + "</td><td>" + rs("au_fname") + "</td><td>" + rs("phone") + "</td><td>" + rs("address") + "</td><td>" + rs("city") + "</td><td>" + rs("state") + "</td><td>" + rs("zip") + "</td></tr>";
rs.moveNext;
}
shtml += "</table>";
documents.write(shtml);
rs.close();
rs = null;
conn.close();
conn = null;
</script>
//使用資料島
<html>
<body>
srno:<input type=text datasrc=#xmldate DataFLD=srno size="76"><BR>
times:<input type=text datasrc=#xmldate DataFLD=times size="76"><BR>
<input id="first" TYPE=button value="<< 第一條記錄" onclick="xmldate.recordset.moveFirst()">
<input id="prev" TYPE=button value="<上一條記錄" onclick="xmldate.recordset.movePrevious()">
<input id="next" TYPE=button value="下一條記錄>" onclick="xmldate.recordset.moveNext()">
<input id="last" TYPE=button value="最後一條記錄>>" onclick="xmldate.recordset.moveLast()">
<input id="Add" TYPE=button value="增加新記錄" onclick="xmldate.recordset.addNew()">
<XML ID="xmldate">
<infolist>
<info ><srno>20041025-01</srno><times>null</times></info>
<info ><srno>20041101-09</srno><times>2004年10月1日2點22分0秒</times></info>
</infolist>
</XML>
</body>
</html>
//獲得參數
<body>
<a href="java script:location.href=location.href + ''?a=1&b=2''">search</a>
<script language="javascript">
<!--
var a = location.search.substr(1);
if(a.length>0)
{
var re = /([^&]*?)\=([^&]*)/g
var s = a.match(re);
for(var i= 0;i<s.length;i++)
{
alert(s);
alert(s.split("=")[1]);
}
}
//-->
</script>
</body>
//可編輯SELECT
<input type=text name=re_name style="width:100px;height:21px;font-size:10pt;"><span style="width:18px;border:0px solid red;"><select name="r00" style="margin-left:-100px;width:118px; background-color:#FFEEEE;" onChange="document.all.re_name.value=this.value;">
<option value="1">11111111<option>
<option value="2">222222</option>
<option value="3">333333</option>
</select>
</span>
//設定光標位置
function getCaret(textbox)
{
var control = document.activeElement;
textbox.focus();
var rang = document.selection.createRange();
rang.setEndPoint("StartToStart",textbox.createTextRange())
control.focus();
return rang.text.length;
}
function setCaret(textbox,pos)
{
try
{
var r =textbox.createTextRange();
r.moveStart(''character'',pos);
r.collapse(true);
r.select();
}
catch(e)
{}
}
function selectLength(textbox,start,len)
{
try
{
var r =textbox.createTextRange();
r.moveEnd(''character'',len-(textbox.value.length-start));
r.moveStart(''character'',start);
r.select();
}
catch(e)
{//alert(e.description)}
}
function insertAtCaret(textbox,text)
{
textbox.focus();
document.selection.createRange().text = text;
}
//頁內搜尋
function findInPage(str)
{
var txt, i, found,n = 0;
if (str == "")
{
return false;
}
txt = document.body.createTextRange();
for (i = 0; i <= n && (found = txt.findText(str)) != false; i++)
{
txt.moveStart("character", 1);
txt.moveEnd("textedit");
}
if (found)
{
txt.moveStart("character", -1);
txt.findText(str);
txt.select();
txt.scrollIntoView();
n++;
}
else
{
if (n > 0)
{
n = 0;
findInPage(str);
}
else
{
alert(str + "... 您要找的文字不存在。\n \n請試著輸入頁面中的關鍵字再次搜尋!");
}
}
return false;
}
//書
www.itpub.net/attachment.php?s=&postid=1894598
www.wrclub.net/down/listdown.aspx?id=1341
//操作EXECL
<script language="javascript">
function jStartExcel() {
var xls = new ActiveXObject ( "Excel.Application" );
xls.visible = true;
var newBook = xls.Workbooks.Add;
newBook.Worksheets.Add;
newBook.Worksheets(1).Activate;
xls.ActiveWorkBook.ActiveSheet.PageSetup.Orientation = 2;
xls.ActiveWorkBook.ActiveSheet.PageSetup.PaperSize = 5;
newBook.Worksheets(1).Columns("A").columnwidth=50;
newBook.Worksheets(1).Columns("A").WrapText = true;
newBook.Worksheets(1).Columns("B").columnwidth=50;
newBook.Worksheets(1).Columns("B").WrapText = true;
newBook.Worksheets(1).Range("A1:B1000").NumberFormat = "0";
newBook.Worksheets(1).Range("A1:B1000").HorizontalAlignment = -4131;
newBook.Worksheets(1).Cells(1,1).Interior.ColorIndex="15";
newBook.Worksheets(1).Cells(1,1).value="First Column, First Cell";
newBook.Worksheets(1).Cells(2,1).value="First Column, Second Cell";
newBook.Worksheets(1).Cells(1,2).value="Second Column, First Cell";
newBook.Worksheets(1).Cells(2,2).value="Second Column, Second Cell";
newBook.Worksheets(1).Name="My First WorkSheet";
}
</script>
//自訂提示條
<a href="#" title="這是提示">tip</a>
<script Language="javascript">
//***********預設設定定義.*********************
tPopWait=50;//停留tWait豪秒後顯示提示。
tPopShow=5000;//顯示tShow豪秒後關閉提示
showPopStep=20;
popOpacity=99;
//***************內部變數定義*****************
sPop=null;
curShow=null;
tFadeOut=null;
tFadeIn=null;
tFadeWaiting=null;
documents.write("<style type=''text/css''id=''defaultPopStyle''>");
documents.write(".cPopText { background-color: #F8F8F5;color:#000000; border: 1px #000000 solid;font-color: font-size: 12px; padding-right: 4px; padding-left: 4px; height: 20px; padding-top: 2px; padding-bottom: 2px; filter: Alpha(Opacity=0)}");
documents.write("</style>");
documents.write("<div id=''dypopLayer'' style=''position:absolute;z-index:1000;'' class=''cPopText''></div>");
function showPopupText(){
var o=event.srcElement;
MouseX=event.x;
MouseY=event.y;
if(o.alt!=null && o.alt!=""){o.dypop=o.alt;o.alt=""};
if(o.title!=null && o.title!=""){o.dypop=o.title;o.title=""};
if(o.dypop!=sPop) {
sPop=o.dypop;
clearTimeout(curShow);
clearTimeout(tFadeOut);
clearTimeout(tFadeIn);
clearTimeout(tFadeWaiting);
if(sPop==null || sPop=="") {
dypopLayer.innerHTML="";
dypopLayer.style.filter="Alpha()";
dypopLayer.filters.Alpha.opacity=0;
}
else {
if(o.dyclass!=null) popStyle=o.dyclass
else popStyle="cPopText";
curShow=setTimeout("showIt()",tPopWait);
}
}
}
function showIt(){
dypopLayer.className=popStyle;
dypopLayer.innerHTML=sPop;
popWidth=dypopLayer.clientWidth;
popHeight=dypopLayer.clientHeight;
if(MouseX+12+popWidth>document.body.clientWidth) popLeftAdjust=-popWidth-24
else popLeftAdjust=0;
if(MouseY+12+popHeight>document.body.clientHeight) popTopAdjust=-popHeight-24
else popTopAdjust=0;
dypopLayer.style.left=MouseX+12+document.body.scrollLeft+popLeftAdjust;
dypopLayer.style.top=MouseY+12+document.body.scrollTop+popTopAdjust;
dypopLayer.style.filter="Alpha(Opacity=0)";
fadeOut();
}
function fadeOut(){
if(dypopLayer.filters.Alpha.opacity<popOpacity) {
dypopLayer.filters.Alpha.opacity+=showPopStep;
tFadeOut=setTimeout("fadeOut()",1);
}
else {
dypopLayer.filters.Alpha.opacity=popOpacity;
tFadeWaiting=setTimeout("fadeIn()",tPopShow);
}
}
function fadeIn(){
if(dypopLayer.filters.Alpha.opacity>0) {
dypopLayer.filters.Alpha.opacity-=1;
tFadeIn=setTimeout("fadeIn()",1);
}
}
document.onmouseover=showPopupText;
</script>
//插入文字
document.onclick =function(){
var oSource = window.event.srcElement;
if(oSource.tagName!="DIV")
return false;
var sel = document.selection;
if (sel!=null) {
var rng = sel.createRange();
if (rng!=null)
rng.pasteHTML("<font color=red>插入文字</font>");
}
}
//netscapte下操作xml
doc = new ActiveXObject("Msxml2.DOMDocument");
doc = new ActiveXObject("Microsoft.XMLDOM")
->>
doc = (new DOMParser()).parseFromString(sXML,''text/xml'')
//判斷鍵值
<html>
<meta http-equiv="Content-Type" content="text/html; charset=big5">
<head>
<script language="javascript">
var ie =navigator.appName=="Microsoft Internet Explorer"?true:false;
function keyDown(e)
{
if(!ie)
{
var nkey=e.which;
var iekey=''現在是ns瀏覽器'';
var realkey=String.fromCharCode(e.which);
}
if(ie)
{
var iekey=event.keyCode;
var nkey=''現在是ie瀏覽器'';
var realkey=String.fromCharCode(event.keyCode);
if(event.keyCode==32){realkey=''\'' 空格\''''}
if(event.keyCode==13){realkey=''\'' 回車\''''}
if(event.keyCode==27){realkey=''\'' Esc\''''}
if(event.keyCode==16){realkey=''\'' Shift\''''}
if(event.keyCode==17){realkey=''\'' Ctrl\''''}
if(event.keyCode==18){realkey=''\'' Alt\''''}
}
alert(''ns瀏覽器中鍵值:''+nkey+''\n''+''ie瀏覽器中鍵值:''+iekey+''\n''+''實際鍵為''+realkey);
}
document.onkeydown = keyDown;
</script>
</head>
<body>
//javascript Document.
<hr>
<center>
<h3>請按任意一個鍵。。。。</h3>
</center>
</body>
</html>
//禁止FSO
1.註銷組件
regsvr32 /u scrrun.dll
2.修改PROGID
HKEY_CLASSES_ROOT\Scripting.FileSystemObject
Scripting.FileSystemObject
3.對於使用object的使用者,修改HKEY_CLASSES_ROOT\Scripting.
//省略號
<DIV STYLE="width: 120px; height: 50px; border: 1px solid blue;
overflow: hidden; text-overflow:ellipsis">
<NOBR>就是比如有一行文字,很長,表格內一行顯示不下.</NOBR>
</DIV>
//檢測media play版本
<IE:clientCaps ID="oClientCaps" style="{behavior:url(#default#clientcaps)}" />
<SCRIPT>
var flash="";
WMPVersion= oClientCaps.getComponentVersion("{22D6F312-B0F6-11D0-94AB-0080C74C7E95}","ComponentID");
if (WMPVersion != "") {
flash = "";
var version = WMPVersion.split(",");
var i;
for (i = 0; i < version.length; i++) {
if (i != 0)
flash += ".";
flash += version;
}
documents.write("您的Windows Media Player 版本是:"+flash+"<p>");
}
</SCRIPT>
//圖像按比例
<script language="javascript">
<!--
//圖片按比例縮放
var flag=false;
function DrawImage(ImgD){
var image=new Image();
var iwidth = 80; //定義允許圖片寬度
var iheight = 80; //定義允許圖片高度
image.src=ImgD.src;
if(image.width>0 && image.height>0){
flag=true;
if(image.width/image.height>= iwidth/iheight){
if(image.width>iwidth){
ImgD.width=iwidth;
ImgD.height=(image.height*iwidth)/image.width;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
ImgD.alt=image.width+"×"+image.height;
}
else{
if(image.height>iheight){
ImgD.height=iheight;
ImgD.width=(image.width*iheight)/image.height;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
ImgD.alt=image.width+"×"+image.height;
}
}
}
//-->
</script>
<img src=".." onload = "DrawImage(this)">
//細線SELECT
<span style="border:1px solid #000000; position:absolute; overflow:hidden;" >
<select style="margin:-2px;">
<option>1111</option>
<option>11111111111111</option>
<option>111111111</option>
</select></span>
標籤:
JavaScript
JavaScript All
轉截 + 微笑過生活 +
事件源對像
event.srcElement.tagName
event.srcElement.type
捕獲釋放
event.srcElement.setCapture();
event.srcElement.releaseCapture();
事件按鍵
event.keyCode
event.shiftKey
event.altKey
event.ctrlKey
事件傳回值
event.returnvalue
滑鼠游標位置
event.x
event.y
窗體活動元素
document.activeElement
鎖定事件
document.captureEvents(Event.KEYDOWN);
瀏覽窗體元素
document.all("txt").focus();
document.all("txt").select();
窗體命令
document.execCommand
窗體COOKIE
documents.cookie
選單事件
document.oncontextmenu
建立元素
document.createElement("SPAN");
根據滑鼠游標獲得元素:
document.elementFromPoint(event.x,event.y).tagName=="TD
document.elementFromPoint(event.x,event.y).appendChild(ms)
窗體圖片
document.images[索引]
窗體事件鎖定
document.onmousedown=scrollwindow;
元素
document.窗體.elements[索引]
對像鎖定事件
document.all.xxx.detachEvent(''onclick'',a);
外掛數目
navigator.plugins
取變數類型
typeof($js_libpath) == "undefined"
下拉選單
下拉選單.options[索引]
下拉選單.options.length
搜尋對像
document.getElementsByName("r1");
document.getElementById(id);
定時
timer=setInterval(''scrollwindow()'',delay);
clearInterval(timer);
UNCODE編碼
escape() ,unescape
父對像
obj.parentElement(dhtml)
obj.parentNode(dom)
交換表的行
TableID.moveRow(2,1)
代換CSS
document.all.csss.href = "a.css";
並排顯示
display:inline
隱藏焦點
hidefocus=true
根據寬度換行
style="word-break:break-all"
自動Reload
<meta HTTP-EQUIV="refresh" CONTENT="8;URL=http://c98.yeah.net">
簡單郵件
<a href="mailto:aaa@bbb.com?subject=ccc&body=xxxyyy">
快速轉到位置
obj.scrollIntoView(true)
錨
<a name="first">
<a href="#first">anchors</a>
網頁傳遞參數
location.search();
可編輯
obj.contenteditable=true
執行選單命令
obj.execCommand
雙字元字元
/[^\x00-\xff]/
漢字
/[\u4e00-\u9fa5]/
讓英文字元串超出表格寬度自動換行
word-wrap: break-word; word-break: break-all;
透明背景
<IFRAME src="1.htm" width=300 height=180 allowtransparency></iframe>
獲得style內容
obj.style.cssText
HTML標籤
document.documentElement.innerHTML
第一個style標籤
document.styleSheets[0]
style標籤裡的第一個樣式
document.styleSheets[0].rules[0]
防止點選空連結時,頁面往往重置到頁首端。
<a href="java script:function()">word</a>
上一網頁源
asp:
request.servervariables("HTTP_REFERER")
java script:
document.referrer
釋放內存
CollectGarbage();
禁止右鍵
document.oncontextmenu = function() { return false;}
禁止儲存
<noscript><iframe src="*.htm"></iframe></noscript>
禁 止選取<body oncontextmenu="return false" ondragstart="return false" onselectstart ="return false" onselect="document.selection.empty()" oncopy="document.selection.empty()" onbeforecopy="return false"onmouseup="document.selection.empty()>
禁止貼上
<input type=text onpaste="return false">
地址欄圖標
<link rel="Shortcut Icon" href="favicon.ico">
favicon.ico 名字最好不變16*16的16色,放虛擬目錄根目錄下
收藏欄圖標
<link rel="Bookmark" href="favicon.ico">
檢視原始碼
<input type=button value=檢視網頁源程式碼 onclick="window.location = ''view-source:''+ ''http://www.csdn.net/''">
關閉輸入法
<input style="ime-mode:disabled">
自動全選
<input type=text name=text1 value="123" onfocus="this.select()">
ENTER鍵可以讓光標移到下一個輸入框
<input onkeydown="if(event.keyCode==13)event.keyCode=9">
文字框的預設值
<input type=text value="123" onfocus="alert(this.defaultvalue)">
title換行
obj.title = "123 sdfs "
獲得時間所代表的微秒
var n1 = new Date("2004-10-10".replace(/-/g, "\/")).getTime()
視窗是否關閉
win.closed
checkbox扁平
<input type=checkbox style="position: absolute; clip:rect(5px 15px 15px 5px)"><br>
獲取選取內容
document.selection.createRange().duplicate().text
自動完成功能
<input type=text autocomplete=on>打開該功能
<input type=text autocomplete=off>關閉該功能
視窗最大化
<body onload="window.resizeTo(window.screen.width - 4,window.screen.height-50);window.moveTo(-4,-4)">
無關閉按鈕IE
windows.open("aa.htm", "meizz", "fullscreen=7");
統一編碼/解碼
alert(decodeURIComponent(encodeURIComponent("http://你好.com?as= hehe")))
encodeURIComponent對":"、"/"、";" 和 "?"也編碼
表格行指示
<tr onmouseover="this.bgColor=''#f0f0f0''" onmouseout="this.bgColor=''#ffffff''">
//各種尺寸
s += "\r\n網頁可見區域寬:"+ document.body.clientWidth;
s += "\r\n網頁可見區域高:"+ document.body.clientHeight;
s += "\r\n網頁可見區域高:"+ document.body.offsetWeight +" (包括邊線的寬)";
s += "\r\n網頁可見區域高:"+ document.body.offsetHeight +" (包括邊線的寬)";
s += "\r\n網頁正文全文寬:"+ document.body.scrollWidth;
s += "\r\n網頁正文全文高:"+ document.body.scrollHeight;
s += "\r\n網頁被捲去的高:"+ document.body.scrollTop;
s += "\r\n網頁被捲去的左:"+ document.body.scrollLeft;
s += "\r\n網頁正文部分上:"+ window.screenTop;
s += "\r\n網頁正文部分左:"+ window.screenLeft;
s += "\r\n螢幕解析度的高:"+ window.screen.height;
s += "\r\n螢幕解析度的寬:"+ window.screen.width;
s += "\r\n螢幕可用工作區高度:"+ window.screen.availHeight;
s += "\r\n螢幕可用工作區寬度:"+ window.screen.availWidth;
//過濾數字
<input type=text onkeypress="return event.keyCode>=48&&event.keyCode<=57||(this.value.indexOf(''.'')<0?event.keyCode==46:false)" onpaste="return !clipboardData.getData(''text'').match(/\D/)" ondragenter="return false">
//特殊用途
<input type=button value=匯入收藏夾 onclick="window.external.ImportExportFavorites(true,''http://localhost'');">
<input type=button value=匯出收藏夾 onclick="window.external.ImportExportFavorites(false,''http://localhost'');">
<input type=button value=整理收藏夾 onclick="window.external.ShowBrowserUI(''OrganizeFavorites'', null)">
<input type=button value=語言設定 onclick="window.external.ShowBrowserUI(''LanguageDialog'', null)">
<input type=button value=加入收藏夾 onclick="window.external.AddFavorite(''http://www.google.com/'', ''google'')">
<input type=button value=加入到頻道 onclick="window.external.addChannel(''http://www.google.com/'')">
<input type=button value=加入到頻道 onclick="window.external.showBrowserUI(''PrivacySettings'',null)">
//不快取
<META HTTP-EQUIV="pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
<META HTTP-EQUIV="expires" CONTENT="0">
//正則匹配
匹配中文字元的正則表達式: [\u4e00-\u9fa5]
匹配雙字元字元(包括漢字在內):[^\x00-\xff]
匹配空行的正則表達式:\n[\s| ]*\r
匹配HTML標記的正則表達式:/<(.*)>.*<\/\1>|<(.*) \/>/
匹配首尾空格的正則表達式:(^\s*)|(\s*$)(像vbscript那樣的trim函數)
匹配Email地址的正則表達式:\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*
匹配網址URL的正則表達式:http://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?
以下是例子:
利用正則表達式限制網頁表單裡的文字框輸入內容:
用 正則表達式限制只能輸入中文:onkeyup="value=value.replace(/[^\u4E00-\u9FA5]/g,'''')" onbeforepaste="clipboardData.setData(''text'',clipboardData.getData(''text'').replace(/[^\u4E00-\u9FA5]/g,''''))"
1. 用正則表達式限制只能輸入全角字元: onkeyup="value=value.replace(/[^\uFF00-\uFFFF]/g,'''')" onbeforepaste="clipboardData.setData(''text'',clipboardData.getData(''text'').replace(/[^\uFF00-\uFFFF]/g,''''))"
2. 用正則表達式限制只能輸入數字:onkeyup="value=value.replace(/[^\d]/g,'''') "onbeforepaste="clipboardData.setData(''text'',clipboardData.getData(''text'').replace(/[^\d]/g,''''))"
3. 用正則表達式限制只能輸入數字和英文:onkeyup="value=value.replace(/[\W]/g,'''') "onbeforepaste="clipboardData.setData(''text'',clipboardData.getData(''text'').replace(/[^\d]/g,''''))"
//消除圖像工具欄
<IMG SRC="mypicture.jpg" HEIGHT="100px" WIDTH="100px" GALLERYIMG="false">
or
<head>
<meta http-equiv="imagetoolbar" content="no">
</head>
//無提示關閉
function Close()
{
var ua=navigator.userAgent
var ie=navigator.appName=="Microsoft Internet Explorer"?true:false
if(ie)
{
var IEversion=parseFloat(ua.substring(ua.indexOf("MSIE ")+5,ua.indexOf(";",ua.indexOf("MSIE "))))
if(IEversion< 5.5)
{
var str = ''<object id=noTipClose classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">''
str += ''<param name="Command" value="Close"></object>'';
document.body.insertAdjacentHTML("beforeEnd", str);
document.all.noTipClose.Click();
}
else
{
windows.opener =null;
window.close();
}
}
else
{
window.close()
}
}
//取得控件得絕對位置(1)
<script language="javascript">
function getoffset(e)
{
var t=e.offsetTop;
var l=e.offsetLeft;
while(e=e.offsetParent)
{
t+=e.offsetTop;
l+=e.offsetLeft;
}
var rec = new Array(1);
rec[0] = t;
rec[1] = l;
return rec
}
</script>
//獲得控件的絕對位置(2)
oRect = obj.getBoundingClientRect();
oRect.left
oRect.
//最小化,最大化,關閉
<object id=min classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">
<param name="Command" value="Minimize"></object>
<object id=max classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">
<param name="Command" value="Maximize"></object>
<OBJECT id=close classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
<PARAM NAME="Command" value="Close"></OBJECT>
<input type=button value=最小化 onclick=min.Click()>
<input type=button value=最大化 onclick=max.Click()>
<input type=button value=關閉 onclick=close.Click()>
//光標停在文字最後
<script language="javascript">
function cc()
{
var e = event.srcElement;
var r =e.createTextRange();
r.moveStart(''character'',e.value.length);
r.collapse(true);
r.select();
}
</script>
<input type=text name=text1 value="123" onfocus="cc()">
//頁面進入和登出的特效
進入頁面<meta http-equiv="Page-Enter" content="revealTrans(duration=x, transition=y)">
推出頁面<meta http-equiv="Page-Exit" content="revealTrans(duration=x, transition=y)">
這個是頁面被載入和調出時的一些特效。duration表示特效的持續時間,以秒為單位。transition表示使
用哪種特效,取值為1-23:
0 矩形縮小
1 矩形擴大
2 圓形縮小
3 圓形擴大
4 下到上Reload
5 上到下Reload
6 左到右Reload
7 右到左Reload
8 豎百葉窗
9 橫百葉窗
10 錯位橫百葉窗
11 錯位豎百葉窗
12 點擴散
13 左右到中間Reload
14 中間到左右Reload
15 中間到上下
16 上下到中間
17 右下到左上
18 右上到左下
19 左上到右下
20 左下到右上
21 橫條
22 豎條
23
//網頁是否被檢索
<meta name="ROBOTS" content="屬性值">
其中屬性值有以下一些:
屬性值為"all": 檔案將被檢索,且頁上連結可被查詢;
屬性值為"none": 檔案不被檢索,而且不查詢頁上的連結;
屬性值為"index": 檔案將被檢索;
屬性值為"follow": 查詢頁上的連結;
屬性值為"noindex": 檔案不檢索,但可被查詢連結;
屬性值為"nofollow":
//打印分頁
<p style="page-break-after:always">page1</p>
<p style="page-break-after:always">page2</p>
//設定打印
<object id="factory" style="display:none" viewastext
classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814"
codebase="http://www.meadroid.com/scriptx/ScriptX.cab#Version=5,60,0,360"
></object>
<input type=button value=頁面設定 onclick="factory.printing.PageSetup()">
<input type=button value=打印預覽 onclick="factory.printing.Preview()">
<script language=javascript>
function window.onload()
{
// -- advanced features
factory.printing.SetMarginMeasure(2) // measure margins in inches
factory.printing.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 = "居左顯示&b置中顯示&b居右顯示頁碼,第&p頁/共&P頁"
factory.printing.footer = "(自訂頁尾)"
factory.printing.portrait = false
factory.printing.leftMargin = 0.75
factory.printing.topMargin = 1.5
factory.printing.rightMargin = 0.75
factory.printing.bottomMargin = 1.5
}
function Print(frame) {
factory.printing.Print(true, frame) // print with prompt
}
</script>
<input type=button value="打印本頁" onclick="factory.printing.Print(false)">
<input type=button value="頁面設定" onclick="factory.printing.PageSetup()">
<input type=button value="打印預覽" onclick="factory.printing.Preview()"><br>
<a href="http://www.meadroid.com/scriptx/docs/printdoc.htm?static" target=_blank>實際使用手冊,更多訊息,點這裡</a>
//自帶的打印預覽
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) Reload
Web.ExecWB(45,1) 關閉窗體無提示
<style media=print>
.Noprint{display:none;}<!--用本樣式在打印時隱藏非打印項目-->
.PageNext{page-break-after: always;}<!--控制分頁-->
</style>
<object id="WebBrowser" width=0 height=0 classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2">
</object>
<center >
<input type=button value=打印 onclick=document.all.WebBrowser.ExecWB(6,1)>
<input type=button value=直接打印 onclick=document.all.WebBrowser.ExecWB(6,6)>
<input type=button value=頁面設定 onclick=document.all.WebBrowser.ExecWB(8,1)>
</p>
<p> <input type=button value=打印預覽 onclick=document.all.WebBrowser.ExecWB(7,1)>
</center>
//去掉打印時的頁眉頁尾
<script language="javascript">
var HKEY_Root,HKEY_Path,HKEY_Key;
HKEY_Root="HKEY_CURRENT_USER";
HKEY_Path="\\Software\\Microsoft\\Internet Explorer\\PageSetup\\";
//設定網頁打印的頁眉頁尾為空白
function PageSetup_Null()
{
try
{
var Wsh=new ActiveXObject("WScript.Shell");
HKEY_Key="header";
Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"");
HKEY_Key="footer";
Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"");
}
catch(e){}
}
//設定網頁打印的頁眉頁尾為預設值
function PageSetup_Default()
{
try
{
var Wsh=new ActiveXObject("WScript.Shell");
HKEY_Key="header";
Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"&w&b頁碼,&p/&P");
HKEY_Key="footer";
Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"&u&b&d");
}
catch(e){}
}
</script>
<input type="button" value="清除頁碼" onclick=PageSetup_Null()>
<input type="button" value="復原頁碼" onclick=PageSetup_Default()>
//瀏覽器驗證
function checkBrowser()
{
this.ver=navigator.appVersion
this.dom=document.getElementById?1:0
this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom)?1:0;
this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
this.ie4=(document.all && !this.dom)?1:0;
this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;
this.ns4=(document.layers && !this.dom)?1:0;
this.mac=(this.ver.indexOf(''Mac'') > -1) ?1:0;
this.ope=(navigator.userAgent.indexOf(''Opera'')>-1);
this.ie=(this.ie6 || this.ie5 || this.ie4)
this.ns=(this.ns4 || this.ns5)
this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns5 || this.ns4 || this.mac || this.ope)
this.nbw=(!this.bw)
return this;
}
//計算內容寬和高
<SCRIPT language="javascript">
function test(obj)
{
var range = obj.createTextRange();
alert("內容區寬度: " + range.boundingWidth
+ "px\r\n內容區高度: " + range.boundingHeight + "px");
}
</SCRIPT>
<BODY>
<Textarea id="txt" height="150">sdf</textarea><INPUT type="button" value="計算內容寬度" onClick="test(txt)">
</BODY>
//無模式的提示框
function modelessAlert(Msg)
{
window.showModelessDialog("java script:alert(\""+escape(Msg)+"\");window.close();","","status:no;resizable:no;help:no;dialogHeight:height:30px;dialogHeight:40px;");
}
//阻斷按鍵
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=big5">
<noscript><meta http-equiv="refresh" content="0;url=about:noscript"></noscript>
<title>阻斷滑鼠游標右鍵、Ctrl+N、Shift+F10、Alt+F4、F11、F5Reload、退格鍵</title>
</head>
<body>
<script language="javascript"><!--
//阻斷滑鼠游標右鍵、Ctrl+N、Shift+F10、F11、F5Reload、退格鍵
//Author: meizz(梅花雨) 2002-6-18
function document.oncontextmenu(){event.returnvalue=false;}//阻斷滑鼠游標右鍵
function window.onhelp(){return false} //阻斷F1輔助
function document.onkeydown()
{
if ((window.event.altKey)&&
((window.event.keyCode==37)|| //阻斷 Alt+ 方向鍵 ←
(window.event.keyCode==39))) //阻斷 Alt+ 方向鍵 →
{
alert("不准你使用ALT+方向鍵前進或後退網頁!");
event.returnvalue=false;
}
/* 註:這還不是真正地阻斷 Alt+ 方向鍵,
因為 Alt+ 方向鍵彈出警告框時,按住 Alt 鍵不放,
用滑鼠游標點掉警告框,這種阻斷方法就失效了。以後若
有哪位高手有真正阻斷 Alt 鍵的方法,請告知。*/
if ((event.keyCode==8) || //阻斷退格刪除鍵
(event.keyCode==116)|| //阻斷 F5 Reload鍵
(event.ctrlKey && event.keyCode==82)){ //Ctrl + R
event.keyCode=0;
event.returnvalue=false;
}
if (event.keyCode==122){event.keyCode=0;event.returnvalue=false;} //阻斷F11
if (event.ctrlKey && event.keyCode==78) event.returnvalue=false; //阻斷 Ctrl+n
if (event.shiftKey && event.keyCode==121)event.returnvalue=false; //阻斷 shift+F10
if (window.event.srcElement.tagName == "A" && window.event.shiftKey)
window.event.returnvalue = false; //阻斷 shift 加滑鼠游標左鍵新開一網頁
if ((window.event.altKey)&&(window.event.keyCode==115)) //阻斷Alt+F4
{
window.showModelessDialog("about:blank","","dialogWidth:1px;dialogheight:1px");
return false;
}
}
</script>
阻斷滑鼠游標右鍵、Ctrl+N、Shift+F10、Alt+F4、F11、F5Reload、退格鍵
</body>
</html>
//阻斷打印
<style>
@media print{
* {display:none}
}
</style>
//移動的圖層,拖動
1.<span style=''position:absolute;width:200;height:200;background:red'' onmousedown=MouseDown(this) onmousemove=MouseMove() onmouseup=MouseUp()>meizz</span>
<script language=javascript>
var Obj;
function MouseDown(obj)
{
Obj=obj;
Obj.setCapture();
Obj.l=event.x-Obj.style.pixelLeft;
Obj.t=event.y-Obj.style.pixelTop;
}
function MouseMove()
{
if(Obj!=null)
{
Obj.style.left = event.x-Obj.l;
Obj.style.top = event.y-Obj.t;
}
}
function MouseUp()
{
if(Obj!=null)
{
Obj.releaseCapture();
Obj=null;
}
}
</script>
2.
<div id="myDiv" src="logo.gif" ondrag="doDrag();" onmouseover="this.style.cursor=''hand''" style="position:absolute;left=100;top=100;" onmousedown="doMouseDown();">
<a href="#" onclick="return false"><h1>wlecome</h1></a>
</div>
<script language="javascript" type="text/javascript">
var orgMouseX;
var orgMouseY;
var orgObjX;
var orgObjY;
function doDrag()
{
var myObject=document.all.myDiv;
var x=event.clientX;
var y=event.clientY;
myObject.style.left=x-(orgMouseX-orgObjX);
myObject.style.top=y-(orgMouseY-orgObjY);
}
function doMouseDown()
{
orgMouseX=event.clientX;
orgMouseY=event.clientY;
orgObjX=parseInt(document.all.myDiv.style.left);
orgObjY=parseInt(document.all.myDiv.style.top);
}
</script>
事件源對像
event.srcElement.tagName
event.srcElement.type
捕獲釋放
event.srcElement.setCapture();
event.srcElement.releaseCapture();
事件按鍵
event.keyCode
event.shiftKey
event.altKey
event.ctrlKey
事件傳回值
event.returnvalue
滑鼠游標位置
event.x
event.y
窗體活動元素
document.activeElement
鎖定事件
document.captureEvents(Event.KEYDOWN);
瀏覽窗體元素
document.all("txt").focus();
document.all("txt").select();
窗體命令
document.execCommand
窗體COOKIE
documents.cookie
選單事件
document.oncontextmenu
建立元素
document.createElement("SPAN");
根據滑鼠游標獲得元素:
document.elementFromPoint(event.x,event.y).tagName=="TD
document.elementFromPoint(event.x,event.y).appendChild(ms)
窗體圖片
document.images[索引]
窗體事件鎖定
document.onmousedown=scrollwindow;
元素
document.窗體.elements[索引]
對像鎖定事件
document.all.xxx.detachEvent(''onclick'',a);
外掛數目
navigator.plugins
取變數類型
typeof($js_libpath) == "undefined"
下拉選單
下拉選單.options[索引]
下拉選單.options.length
搜尋對像
document.getElementsByName("r1");
document.getElementById(id);
定時
timer=setInterval(''scrollwindow()'',delay);
clearInterval(timer);
UNCODE編碼
escape() ,unescape
父對像
obj.parentElement(dhtml)
obj.parentNode(dom)
交換表的行
TableID.moveRow(2,1)
代換CSS
document.all.csss.href = "a.css";
並排顯示
display:inline
隱藏焦點
hidefocus=true
根據寬度換行
style="word-break:break-all"
自動Reload
<meta HTTP-EQUIV="refresh" CONTENT="8;URL=http://c98.yeah.net">
簡單郵件
<a href="mailto:aaa@bbb.com?subject=ccc&body=xxxyyy">
快速轉到位置
obj.scrollIntoView(true)
錨
<a name="first">
<a href="#first">anchors</a>
網頁傳遞參數
location.search();
可編輯
obj.contenteditable=true
執行選單命令
obj.execCommand
雙字元字元
/[^\x00-\xff]/
漢字
/[\u4e00-\u9fa5]/
讓英文字元串超出表格寬度自動換行
word-wrap: break-word; word-break: break-all;
透明背景
<IFRAME src="1.htm" width=300 height=180 allowtransparency></iframe>
獲得style內容
obj.style.cssText
HTML標籤
document.documentElement.innerHTML
第一個style標籤
document.styleSheets[0]
style標籤裡的第一個樣式
document.styleSheets[0].rules[0]
防止點選空連結時,頁面往往重置到頁首端。
<a href="java script:function()">word</a>
上一網頁源
asp:
request.servervariables("HTTP_REFERER")
java script:
document.referrer
釋放內存
CollectGarbage();
禁止右鍵
document.oncontextmenu = function() { return false;}
禁止儲存
<noscript><iframe src="*.htm"></iframe></noscript>
禁 止選取<body oncontextmenu="return false" ondragstart="return false" onselectstart ="return false" onselect="document.selection.empty()" oncopy="document.selection.empty()" onbeforecopy="return false"onmouseup="document.selection.empty()>
禁止貼上
<input type=text onpaste="return false">
地址欄圖標
<link rel="Shortcut Icon" href="favicon.ico">
favicon.ico 名字最好不變16*16的16色,放虛擬目錄根目錄下
收藏欄圖標
<link rel="Bookmark" href="favicon.ico">
檢視原始碼
<input type=button value=檢視網頁源程式碼 onclick="window.location = ''view-source:''+ ''http://www.csdn.net/''">
關閉輸入法
<input style="ime-mode:disabled">
自動全選
<input type=text name=text1 value="123" onfocus="this.select()">
ENTER鍵可以讓光標移到下一個輸入框
<input onkeydown="if(event.keyCode==13)event.keyCode=9">
文字框的預設值
<input type=text value="123" onfocus="alert(this.defaultvalue)">
title換行
obj.title = "123 sdfs "
獲得時間所代表的微秒
var n1 = new Date("2004-10-10".replace(/-/g, "\/")).getTime()
視窗是否關閉
win.closed
checkbox扁平
<input type=checkbox style="position: absolute; clip:rect(5px 15px 15px 5px)"><br>
獲取選取內容
document.selection.createRange().duplicate().text
自動完成功能
<input type=text autocomplete=on>打開該功能
<input type=text autocomplete=off>關閉該功能
視窗最大化
<body onload="window.resizeTo(window.screen.width - 4,window.screen.height-50);window.moveTo(-4,-4)">
無關閉按鈕IE
windows.open("aa.htm", "meizz", "fullscreen=7");
統一編碼/解碼
alert(decodeURIComponent(encodeURIComponent("http://你好.com?as= hehe")))
encodeURIComponent對":"、"/"、";" 和 "?"也編碼
表格行指示
<tr onmouseover="this.bgColor=''#f0f0f0''" onmouseout="this.bgColor=''#ffffff''">
//各種尺寸
s += "\r\n網頁可見區域寬:"+ document.body.clientWidth;
s += "\r\n網頁可見區域高:"+ document.body.clientHeight;
s += "\r\n網頁可見區域高:"+ document.body.offsetWeight +" (包括邊線的寬)";
s += "\r\n網頁可見區域高:"+ document.body.offsetHeight +" (包括邊線的寬)";
s += "\r\n網頁正文全文寬:"+ document.body.scrollWidth;
s += "\r\n網頁正文全文高:"+ document.body.scrollHeight;
s += "\r\n網頁被捲去的高:"+ document.body.scrollTop;
s += "\r\n網頁被捲去的左:"+ document.body.scrollLeft;
s += "\r\n網頁正文部分上:"+ window.screenTop;
s += "\r\n網頁正文部分左:"+ window.screenLeft;
s += "\r\n螢幕解析度的高:"+ window.screen.height;
s += "\r\n螢幕解析度的寬:"+ window.screen.width;
s += "\r\n螢幕可用工作區高度:"+ window.screen.availHeight;
s += "\r\n螢幕可用工作區寬度:"+ window.screen.availWidth;
//過濾數字
<input type=text onkeypress="return event.keyCode>=48&&event.keyCode<=57||(this.value.indexOf(''.'')<0?event.keyCode==46:false)" onpaste="return !clipboardData.getData(''text'').match(/\D/)" ondragenter="return false">
//特殊用途
<input type=button value=匯入收藏夾 onclick="window.external.ImportExportFavorites(true,''http://localhost'');">
<input type=button value=匯出收藏夾 onclick="window.external.ImportExportFavorites(false,''http://localhost'');">
<input type=button value=整理收藏夾 onclick="window.external.ShowBrowserUI(''OrganizeFavorites'', null)">
<input type=button value=語言設定 onclick="window.external.ShowBrowserUI(''LanguageDialog'', null)">
<input type=button value=加入收藏夾 onclick="window.external.AddFavorite(''http://www.google.com/'', ''google'')">
<input type=button value=加入到頻道 onclick="window.external.addChannel(''http://www.google.com/'')">
<input type=button value=加入到頻道 onclick="window.external.showBrowserUI(''PrivacySettings'',null)">
//不快取
<META HTTP-EQUIV="pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
<META HTTP-EQUIV="expires" CONTENT="0">
//正則匹配
匹配中文字元的正則表達式: [\u4e00-\u9fa5]
匹配雙字元字元(包括漢字在內):[^\x00-\xff]
匹配空行的正則表達式:\n[\s| ]*\r
匹配HTML標記的正則表達式:/<(.*)>.*<\/\1>|<(.*) \/>/
匹配首尾空格的正則表達式:(^\s*)|(\s*$)(像vbscript那樣的trim函數)
匹配Email地址的正則表達式:\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*
匹配網址URL的正則表達式:http://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?
以下是例子:
利用正則表達式限制網頁表單裡的文字框輸入內容:
用 正則表達式限制只能輸入中文:onkeyup="value=value.replace(/[^\u4E00-\u9FA5]/g,'''')" onbeforepaste="clipboardData.setData(''text'',clipboardData.getData(''text'').replace(/[^\u4E00-\u9FA5]/g,''''))"
1. 用正則表達式限制只能輸入全角字元: onkeyup="value=value.replace(/[^\uFF00-\uFFFF]/g,'''')" onbeforepaste="clipboardData.setData(''text'',clipboardData.getData(''text'').replace(/[^\uFF00-\uFFFF]/g,''''))"
2. 用正則表達式限制只能輸入數字:onkeyup="value=value.replace(/[^\d]/g,'''') "onbeforepaste="clipboardData.setData(''text'',clipboardData.getData(''text'').replace(/[^\d]/g,''''))"
3. 用正則表達式限制只能輸入數字和英文:onkeyup="value=value.replace(/[\W]/g,'''') "onbeforepaste="clipboardData.setData(''text'',clipboardData.getData(''text'').replace(/[^\d]/g,''''))"
//消除圖像工具欄
<IMG SRC="mypicture.jpg" HEIGHT="100px" WIDTH="100px" GALLERYIMG="false">
or
<head>
<meta http-equiv="imagetoolbar" content="no">
</head>
//無提示關閉
function Close()
{
var ua=navigator.userAgent
var ie=navigator.appName=="Microsoft Internet Explorer"?true:false
if(ie)
{
var IEversion=parseFloat(ua.substring(ua.indexOf("MSIE ")+5,ua.indexOf(";",ua.indexOf("MSIE "))))
if(IEversion< 5.5)
{
var str = ''<object id=noTipClose classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">''
str += ''<param name="Command" value="Close"></object>'';
document.body.insertAdjacentHTML("beforeEnd", str);
document.all.noTipClose.Click();
}
else
{
windows.opener =null;
window.close();
}
}
else
{
window.close()
}
}
//取得控件得絕對位置(1)
<script language="javascript">
function getoffset(e)
{
var t=e.offsetTop;
var l=e.offsetLeft;
while(e=e.offsetParent)
{
t+=e.offsetTop;
l+=e.offsetLeft;
}
var rec = new Array(1);
rec[0] = t;
rec[1] = l;
return rec
}
</script>
//獲得控件的絕對位置(2)
oRect = obj.getBoundingClientRect();
oRect.left
oRect.
//最小化,最大化,關閉
<object id=min classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">
<param name="Command" value="Minimize"></object>
<object id=max classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">
<param name="Command" value="Maximize"></object>
<OBJECT id=close classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
<PARAM NAME="Command" value="Close"></OBJECT>
<input type=button value=最小化 onclick=min.Click()>
<input type=button value=最大化 onclick=max.Click()>
<input type=button value=關閉 onclick=close.Click()>
//光標停在文字最後
<script language="javascript">
function cc()
{
var e = event.srcElement;
var r =e.createTextRange();
r.moveStart(''character'',e.value.length);
r.collapse(true);
r.select();
}
</script>
<input type=text name=text1 value="123" onfocus="cc()">
//頁面進入和登出的特效
進入頁面<meta http-equiv="Page-Enter" content="revealTrans(duration=x, transition=y)">
推出頁面<meta http-equiv="Page-Exit" content="revealTrans(duration=x, transition=y)">
這個是頁面被載入和調出時的一些特效。duration表示特效的持續時間,以秒為單位。transition表示使
用哪種特效,取值為1-23:
0 矩形縮小
1 矩形擴大
2 圓形縮小
3 圓形擴大
4 下到上Reload
5 上到下Reload
6 左到右Reload
7 右到左Reload
8 豎百葉窗
9 橫百葉窗
10 錯位橫百葉窗
11 錯位豎百葉窗
12 點擴散
13 左右到中間Reload
14 中間到左右Reload
15 中間到上下
16 上下到中間
17 右下到左上
18 右上到左下
19 左上到右下
20 左下到右上
21 橫條
22 豎條
23
//網頁是否被檢索
<meta name="ROBOTS" content="屬性值">
其中屬性值有以下一些:
屬性值為"all": 檔案將被檢索,且頁上連結可被查詢;
屬性值為"none": 檔案不被檢索,而且不查詢頁上的連結;
屬性值為"index": 檔案將被檢索;
屬性值為"follow": 查詢頁上的連結;
屬性值為"noindex": 檔案不檢索,但可被查詢連結;
屬性值為"nofollow":
//打印分頁
<p style="page-break-after:always">page1</p>
<p style="page-break-after:always">page2</p>
//設定打印
<object id="factory" style="display:none" viewastext
classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814"
codebase="http://www.meadroid.com/scriptx/ScriptX.cab#Version=5,60,0,360"
></object>
<input type=button value=頁面設定 onclick="factory.printing.PageSetup()">
<input type=button value=打印預覽 onclick="factory.printing.Preview()">
<script language=javascript>
function window.onload()
{
// -- advanced features
factory.printing.SetMarginMeasure(2) // measure margins in inches
factory.printing.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 = "居左顯示&b置中顯示&b居右顯示頁碼,第&p頁/共&P頁"
factory.printing.footer = "(自訂頁尾)"
factory.printing.portrait = false
factory.printing.leftMargin = 0.75
factory.printing.topMargin = 1.5
factory.printing.rightMargin = 0.75
factory.printing.bottomMargin = 1.5
}
function Print(frame) {
factory.printing.Print(true, frame) // print with prompt
}
</script>
<input type=button value="打印本頁" onclick="factory.printing.Print(false)">
<input type=button value="頁面設定" onclick="factory.printing.PageSetup()">
<input type=button value="打印預覽" onclick="factory.printing.Preview()"><br>
<a href="http://www.meadroid.com/scriptx/docs/printdoc.htm?static" target=_blank>實際使用手冊,更多訊息,點這裡</a>
//自帶的打印預覽
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) Reload
Web.ExecWB(45,1) 關閉窗體無提示
<style media=print>
.Noprint{display:none;}<!--用本樣式在打印時隱藏非打印項目-->
.PageNext{page-break-after: always;}<!--控制分頁-->
</style>
<object id="WebBrowser" width=0 height=0 classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2">
</object>
<center >
<input type=button value=打印 onclick=document.all.WebBrowser.ExecWB(6,1)>
<input type=button value=直接打印 onclick=document.all.WebBrowser.ExecWB(6,6)>
<input type=button value=頁面設定 onclick=document.all.WebBrowser.ExecWB(8,1)>
</p>
<p> <input type=button value=打印預覽 onclick=document.all.WebBrowser.ExecWB(7,1)>
</center>
//去掉打印時的頁眉頁尾
<script language="javascript">
var HKEY_Root,HKEY_Path,HKEY_Key;
HKEY_Root="HKEY_CURRENT_USER";
HKEY_Path="\\Software\\Microsoft\\Internet Explorer\\PageSetup\\";
//設定網頁打印的頁眉頁尾為空白
function PageSetup_Null()
{
try
{
var Wsh=new ActiveXObject("WScript.Shell");
HKEY_Key="header";
Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"");
HKEY_Key="footer";
Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"");
}
catch(e){}
}
//設定網頁打印的頁眉頁尾為預設值
function PageSetup_Default()
{
try
{
var Wsh=new ActiveXObject("WScript.Shell");
HKEY_Key="header";
Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"&w&b頁碼,&p/&P");
HKEY_Key="footer";
Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"&u&b&d");
}
catch(e){}
}
</script>
<input type="button" value="清除頁碼" onclick=PageSetup_Null()>
<input type="button" value="復原頁碼" onclick=PageSetup_Default()>
//瀏覽器驗證
function checkBrowser()
{
this.ver=navigator.appVersion
this.dom=document.getElementById?1:0
this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom)?1:0;
this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
this.ie4=(document.all && !this.dom)?1:0;
this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;
this.ns4=(document.layers && !this.dom)?1:0;
this.mac=(this.ver.indexOf(''Mac'') > -1) ?1:0;
this.ope=(navigator.userAgent.indexOf(''Opera'')>-1);
this.ie=(this.ie6 || this.ie5 || this.ie4)
this.ns=(this.ns4 || this.ns5)
this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns5 || this.ns4 || this.mac || this.ope)
this.nbw=(!this.bw)
return this;
}
//計算內容寬和高
<SCRIPT language="javascript">
function test(obj)
{
var range = obj.createTextRange();
alert("內容區寬度: " + range.boundingWidth
+ "px\r\n內容區高度: " + range.boundingHeight + "px");
}
</SCRIPT>
<BODY>
<Textarea id="txt" height="150">sdf</textarea><INPUT type="button" value="計算內容寬度" onClick="test(txt)">
</BODY>
//無模式的提示框
function modelessAlert(Msg)
{
window.showModelessDialog("java script:alert(\""+escape(Msg)+"\");window.close();","","status:no;resizable:no;help:no;dialogHeight:height:30px;dialogHeight:40px;");
}
//阻斷按鍵
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=big5">
<noscript><meta http-equiv="refresh" content="0;url=about:noscript"></noscript>
<title>阻斷滑鼠游標右鍵、Ctrl+N、Shift+F10、Alt+F4、F11、F5Reload、退格鍵</title>
</head>
<body>
<script language="javascript"><!--
//阻斷滑鼠游標右鍵、Ctrl+N、Shift+F10、F11、F5Reload、退格鍵
//Author: meizz(梅花雨) 2002-6-18
function document.oncontextmenu(){event.returnvalue=false;}//阻斷滑鼠游標右鍵
function window.onhelp(){return false} //阻斷F1輔助
function document.onkeydown()
{
if ((window.event.altKey)&&
((window.event.keyCode==37)|| //阻斷 Alt+ 方向鍵 ←
(window.event.keyCode==39))) //阻斷 Alt+ 方向鍵 →
{
alert("不准你使用ALT+方向鍵前進或後退網頁!");
event.returnvalue=false;
}
/* 註:這還不是真正地阻斷 Alt+ 方向鍵,
因為 Alt+ 方向鍵彈出警告框時,按住 Alt 鍵不放,
用滑鼠游標點掉警告框,這種阻斷方法就失效了。以後若
有哪位高手有真正阻斷 Alt 鍵的方法,請告知。*/
if ((event.keyCode==8) || //阻斷退格刪除鍵
(event.keyCode==116)|| //阻斷 F5 Reload鍵
(event.ctrlKey && event.keyCode==82)){ //Ctrl + R
event.keyCode=0;
event.returnvalue=false;
}
if (event.keyCode==122){event.keyCode=0;event.returnvalue=false;} //阻斷F11
if (event.ctrlKey && event.keyCode==78) event.returnvalue=false; //阻斷 Ctrl+n
if (event.shiftKey && event.keyCode==121)event.returnvalue=false; //阻斷 shift+F10
if (window.event.srcElement.tagName == "A" && window.event.shiftKey)
window.event.returnvalue = false; //阻斷 shift 加滑鼠游標左鍵新開一網頁
if ((window.event.altKey)&&(window.event.keyCode==115)) //阻斷Alt+F4
{
window.showModelessDialog("about:blank","","dialogWidth:1px;dialogheight:1px");
return false;
}
}
</script>
阻斷滑鼠游標右鍵、Ctrl+N、Shift+F10、Alt+F4、F11、F5Reload、退格鍵
</body>
</html>
//阻斷打印
<style>
@media print{
* {display:none}
}
</style>
//移動的圖層,拖動
1.<span style=''position:absolute;width:200;height:200;background:red'' onmousedown=MouseDown(this) onmousemove=MouseMove() onmouseup=MouseUp()>meizz</span>
<script language=javascript>
var Obj;
function MouseDown(obj)
{
Obj=obj;
Obj.setCapture();
Obj.l=event.x-Obj.style.pixelLeft;
Obj.t=event.y-Obj.style.pixelTop;
}
function MouseMove()
{
if(Obj!=null)
{
Obj.style.left = event.x-Obj.l;
Obj.style.top = event.y-Obj.t;
}
}
function MouseUp()
{
if(Obj!=null)
{
Obj.releaseCapture();
Obj=null;
}
}
</script>
2.
<div id="myDiv" src="logo.gif" ondrag="doDrag();" onmouseover="this.style.cursor=''hand''" style="position:absolute;left=100;top=100;" onmousedown="doMouseDown();">
<a href="#" onclick="return false"><h1>wlecome</h1></a>
</div>
<script language="javascript" type="text/javascript">
var orgMouseX;
var orgMouseY;
var orgObjX;
var orgObjY;
function doDrag()
{
var myObject=document.all.myDiv;
var x=event.clientX;
var y=event.clientY;
myObject.style.left=x-(orgMouseX-orgObjX);
myObject.style.top=y-(orgMouseY-orgObjY);
}
function doMouseDown()
{
orgMouseX=event.clientX;
orgMouseY=event.clientY;
orgObjX=parseInt(document.all.myDiv.style.left);
orgObjY=parseInt(document.all.myDiv.style.top);
}
</script>
標籤:
JavaScript
JavaScript - Dom
轉截 平凡的世界
對象屬性
document.title //設置文檔標題等價於HTML的title標籤
document.bgColor //設置頁面背景色
document.fgColor //設置前景色(文本顏色)
document.linkColor //未點擊過的鏈接顏色
document.alinkColor //激活鏈接(焦點在此鏈接上)的顏色
document.vlinkColor //已點擊過的鏈接顏色
document.URL //設置URL屬性從而在同一窗口打開另一網頁
document.fileCreatedDate //文件建立日期,只讀屬性
document.fileModifiedDate //文件修改日期,只讀屬性
document.fileSize //文件大小,只讀屬性
document.cookie //設置和讀出cookie
document.charset //設置字符集 簡體中文:gb2312
———————————————————————
常用對象方法
document.write() //動態向頁面寫入內容
document.createElement(Tag) //創建一個html標籤對象
document.getElementById(ID) //獲得指定ID值的對象
document.getElementsByName(Name) //獲得指定Name值的對象
document.body.appendChild(oTag)
———————————————————————
body-主體子對象
document.body //指定文檔主體的開始和結束等價於body>/body>
document.body.bgColor //設置或獲取對象後面的背景顏色
document.body.link //未點擊過的鏈接顏色
document.body.alink //激活鏈接(焦點在此鏈接上)的顏色
document.body.vlink //已點擊過的鏈接顏色
document.body.text //文本色
document.body.innerText //設置body>…/body>之間的文本
document.body.innerHTML //設置body>…/body>之間的HTML代碼
document.body.topMargin //頁面上邊距
document.body.leftMargin //頁面左邊距
document.body.rightMargin //頁面右邊距
document.body.bottomMargin //頁面下邊距
document.body.background //背景圖片
document.body.appendChild(oTag) //動態生成一個HTML對象
常用對象事件
document.body.onclick=」func()」 //鼠標指針單擊對象是觸發
document.body.onmouseover=」func()」 //鼠標指針移到對象時觸發
document.body.onmouseout=」func()」 //鼠標指針移出對象時觸發
———————————————————————
location-位置子對象
document.location.hash // #號後的部分
document.location.host // 域名+端口號
document.location.hostname // 域名
document.location.href // 完整URL
document.location.pathname // 目錄部分
document.location.port // 端口號
document.location.protocol // 網絡協議(http:)
document.location.search // ?號後的部分
documeny.location.reload() //刷新網頁
document.location.reload(URL) //打開新的網頁
document.location.assign(URL) //打開新的網頁
document.location.replace(URL) //打開新的網頁
———————————————————————
selection-選區子對象
document.selection
———————————————————————
images集合(頁面中的圖像)
a)通過集合引用
document.images //對應頁面上的img標籤
document.images.length //對應頁面上img標籤的個數
document.images[0] //第1個img標籤
document.images[i] //第i-1個img標籤
b)通過nane屬性直接引用
img name=」oImage」
document.images.oImage //document.images.name屬性
c)引用圖片的src屬性
document.images.oImage.src //document.images.name屬性.src
d)創建一個圖像
var oImage
oImage = new Image()
document.images.oImage.src=」1.jpg」
同時在頁面上建立一個img /標籤與之對應就可以顯示
———————————————————————-
forms集合(頁面中的表單)
a)通過集合引用
document.forms //對應頁面上的form標籤
document.forms.length //對應頁面上/formform標籤的個數
document.forms[0] //第1個/formform標籤
document.forms[i] //第i-1個/formform標籤
document.forms[i].length //第i-1個/formform中的控件數
document.forms[i].elements[j] //第i-1個/formform中第j-1個控件
b)通過標籤name屬性直接引用
/formform name=」Myform」>input name=」myctrl」/>/form
document.Myform.myctrl //document.表單名.控件名
c)訪問表單的屬性
document.forms[i].name //對應form name>屬性
document.forms[i].action //對應/formform action>屬性
document.forms[i].encoding //對應/formform enctype>屬性
document.forms[i].target //對應/formform target>屬性
document.forms[i].appendChild(oTag) //動態插入一個控件
document.all.oDiv //引用圖層oDiv
document.all.oDiv.style.display=」" //圖層設置為可視
document.all.oDiv.style.display=」none」 //圖層設置為隱藏
document.getElementId(」oDiv」) //通過getElementId引用對象
document.getElementId(」oDiv」).style=」"
document.getElementId(」oDiv」).display=」none」
/*document.all表示document中所有對象的集合
只有ie支持此屬性,因此也用來判斷瀏覽器的種類*/
圖層對象的4個屬性
document.getElementById(」ID」).innerText //動態輸出文本
document.getElementById(」ID」).innerHTML //動態輸出HTML
document.getElementById(」ID」).outerText //同innerText
document.getElementById(」ID」).outerHTML //同innerHTML
對象屬性
document.title //設置文檔標題等價於HTML的title標籤
document.bgColor //設置頁面背景色
document.fgColor //設置前景色(文本顏色)
document.linkColor //未點擊過的鏈接顏色
document.alinkColor //激活鏈接(焦點在此鏈接上)的顏色
document.vlinkColor //已點擊過的鏈接顏色
document.URL //設置URL屬性從而在同一窗口打開另一網頁
document.fileCreatedDate //文件建立日期,只讀屬性
document.fileModifiedDate //文件修改日期,只讀屬性
document.fileSize //文件大小,只讀屬性
document.cookie //設置和讀出cookie
document.charset //設置字符集 簡體中文:gb2312
———————————————————————
常用對象方法
document.write() //動態向頁面寫入內容
document.createElement(Tag) //創建一個html標籤對象
document.getElementById(ID) //獲得指定ID值的對象
document.getElementsByName(Name) //獲得指定Name值的對象
document.body.appendChild(oTag)
———————————————————————
body-主體子對象
document.body //指定文檔主體的開始和結束等價於body>/body>
document.body.bgColor //設置或獲取對象後面的背景顏色
document.body.link //未點擊過的鏈接顏色
document.body.alink //激活鏈接(焦點在此鏈接上)的顏色
document.body.vlink //已點擊過的鏈接顏色
document.body.text //文本色
document.body.innerText //設置body>…/body>之間的文本
document.body.innerHTML //設置body>…/body>之間的HTML代碼
document.body.topMargin //頁面上邊距
document.body.leftMargin //頁面左邊距
document.body.rightMargin //頁面右邊距
document.body.bottomMargin //頁面下邊距
document.body.background //背景圖片
document.body.appendChild(oTag) //動態生成一個HTML對象
常用對象事件
document.body.onclick=」func()」 //鼠標指針單擊對象是觸發
document.body.onmouseover=」func()」 //鼠標指針移到對象時觸發
document.body.onmouseout=」func()」 //鼠標指針移出對象時觸發
———————————————————————
location-位置子對象
document.location.hash // #號後的部分
document.location.host // 域名+端口號
document.location.hostname // 域名
document.location.href // 完整URL
document.location.pathname // 目錄部分
document.location.port // 端口號
document.location.protocol // 網絡協議(http:)
document.location.search // ?號後的部分
documeny.location.reload() //刷新網頁
document.location.reload(URL) //打開新的網頁
document.location.assign(URL) //打開新的網頁
document.location.replace(URL) //打開新的網頁
———————————————————————
selection-選區子對象
document.selection
———————————————————————
images集合(頁面中的圖像)
a)通過集合引用
document.images //對應頁面上的img標籤
document.images.length //對應頁面上img標籤的個數
document.images[0] //第1個img標籤
document.images[i] //第i-1個img標籤
b)通過nane屬性直接引用
img name=」oImage」
document.images.oImage //document.images.name屬性
c)引用圖片的src屬性
document.images.oImage.src //document.images.name屬性.src
d)創建一個圖像
var oImage
oImage = new Image()
document.images.oImage.src=」1.jpg」
同時在頁面上建立一個img /標籤與之對應就可以顯示
———————————————————————-
forms集合(頁面中的表單)
a)通過集合引用
document.forms //對應頁面上的form標籤
document.forms.length //對應頁面上/formform標籤的個數
document.forms[0] //第1個/formform標籤
document.forms[i] //第i-1個/formform標籤
document.forms[i].length //第i-1個/formform中的控件數
document.forms[i].elements[j] //第i-1個/formform中第j-1個控件
b)通過標籤name屬性直接引用
/formform name=」Myform」>input name=」myctrl」/>/form
document.Myform.myctrl //document.表單名.控件名
c)訪問表單的屬性
document.forms[i].name //對應form name>屬性
document.forms[i].action //對應/formform action>屬性
document.forms[i].encoding //對應/formform enctype>屬性
document.forms[i].target //對應/formform target>屬性
document.forms[i].appendChild(oTag) //動態插入一個控件
document.all.oDiv //引用圖層oDiv
document.all.oDiv.style.display=」" //圖層設置為可視
document.all.oDiv.style.display=」none」 //圖層設置為隱藏
document.getElementId(」oDiv」) //通過getElementId引用對象
document.getElementId(」oDiv」).style=」"
document.getElementId(」oDiv」).display=」none」
/*document.all表示document中所有對象的集合
只有ie支持此屬性,因此也用來判斷瀏覽器的種類*/
圖層對象的4個屬性
document.getElementById(」ID」).innerText //動態輸出文本
document.getElementById(」ID」).innerHTML //動態輸出HTML
document.getElementById(」ID」).outerText //同innerText
document.getElementById(」ID」).outerHTML //同innerHTML
標籤:
JavaScript
2012年2月24日 星期五
2012年2月17日 星期五
DIV 加入scrollbar
ex :overflow-x: hidden; overflow-y: scroll;"
overflow:控制當內容超過顯示區域時捲軸的顯示
overflow-x: X軸
overflow-y:Y軸
overflow{
visible(預設):不顯示scrollbar
auto:視情況顯示scrollbar(水平&垂直)
scroll:顯示scrollbar(水平&垂直)、視情況是否可捲動
hidden:隱藏scrollbar(水平&垂直)
}
標籤:
JavaScript
2012年2月7日 星期二
MyEclipse6.5安裝SVN
SVN套件url:http://subclipse.tigris.org/files/documents/906/46495/site-1.6.5.zip
1. MyEclipse 6.5目錄中(eclipse\plug_ins)下新建文件夾:site-1.6.5;
2. 開啟MyEclipse 6.5,工作列選擇Help → Software Updates → Find and Install;
3. 選Search for new features to install→Next→"New Local Site"
4. 選解壓出來的文件夾(site-1.6.5) → OK→Finish
5. pop window list,打勾Subclipse-site-1.6.5,會報錯,然後展開Subclipse前的加號,取消(Subclipse Integration for Mylyn 3.x(Optional)3.0.0),
錯誤消失→ next → "I accept " → next → next → select all→ "Change Location"
6.list選Add Location……選第2步中新增的文件(site-1.6.5)→ Finish → 再彈出的菜單中選Install All → Yes→開始安裝SVN插件,安裝完成之後,重啟Myeclipse。
方法三、無法連接網絡的情況(link鏈接)
1、從官網下載Site-1.6.5.zip
2、解壓Site-1.6.5.zip至${eclipse}\Plugins\Subclipse-1.6.5.zip,並刪除site.xml(很重要)
(即把Site-1.6.5.zip解壓出來的features和plugins文件夾裡所有的jar包和兩個XML文件artifacts.xml、content.xml添加並替換到plugins文件夾下。
ex:C:\Program Files\MyEclipse 6.5\eclipse\plugins\目錄下)
3、建立捷徑${eclipse}\linksSubclipse-1.6.5.zip.link (即在link文件夾下添加linksSubclipse-1.6.5.link文件)其內容為: path=C:\Program Files\MyEclipse 6.5 \eclipse\
4、重啟Eclipse就是把subclipse集成完畢
本文摘自:http://lilindawan.javaeye.com/blog/798232
1. MyEclipse 6.5目錄中(eclipse\plug_ins)下新建文件夾:site-1.6.5;
2. 開啟MyEclipse 6.5,工作列選擇Help → Software Updates → Find and Install;
3. 選Search for new features to install→Next→"New Local Site"
4. 選解壓出來的文件夾(site-1.6.5) → OK→Finish
5. pop window list,打勾Subclipse-site-1.6.5,會報錯,然後展開Subclipse前的加號,取消(Subclipse Integration for Mylyn 3.x(Optional)3.0.0),
錯誤消失→ next → "I accept " → next → next → select all→ "Change Location"
6.list選Add Location……選第2步中新增的文件(site-1.6.5)→ Finish → 再彈出的菜單中選Install All → Yes→開始安裝SVN插件,安裝完成之後,重啟Myeclipse。
方法三、無法連接網絡的情況(link鏈接)
1、從官網下載Site-1.6.5.zip
2、解壓Site-1.6.5.zip至${eclipse}\Plugins\Subclipse-1.6.5.zip,並刪除site.xml(很重要)
(即把Site-1.6.5.zip解壓出來的features和plugins文件夾裡所有的jar包和兩個XML文件artifacts.xml、content.xml添加並替換到plugins文件夾下。
ex:C:\Program Files\MyEclipse 6.5\eclipse\plugins\目錄下)
3、建立捷徑${eclipse}\linksSubclipse-1.6.5.zip.link (即在link文件夾下添加linksSubclipse-1.6.5.link文件)其內容為: path=C:\Program Files\MyEclipse 6.5 \eclipse\
4、重啟Eclipse就是把subclipse集成完畢
本文摘自:http://lilindawan.javaeye.com/blog/798232
標籤:
Tool
2012年2月6日 星期一
20120205 北海岸約騎
時間:2012/02/05
地點:北海岸(90k入帳)
人員:天輝大哥、小白("獸"星)、嘉濰、小勳、v奶爸、 小花夫婦
久違的約騎、決定開始報半馬練到現在也一個多月了、跑步影響最近騎車踩踏的齒比、越來越嚴重...以前同樣路段大概只有19/17 現在17/15 甚至13
70K左右、就覺的四頭肌明顯沒力了(加上前天的12K..還沒恢復)
距離3/18剩一個多月了~希望完賽、也希望時間在預計上(2:1X上下)
地點:北海岸(90k入帳)
人員:天輝大哥、小白("獸"星)、嘉濰、小勳、v奶爸、 小花夫婦
久違的約騎、決定開始報半馬練到現在也一個多月了、跑步影響最近騎車踩踏的齒比、越來越嚴重...以前同樣路段大概只有19/17 現在17/15 甚至13
70K左右、就覺的四頭肌明顯沒力了(加上前天的12K..還沒恢復)
距離3/18剩一個多月了~希望完賽、也希望時間在預計上(2:1X上下)
2012年2月2日 星期四
2012 0201 11.7rec
微風運河一圈3.91k<括號為最佳時間>
Round 1 23:47<22:32.69>
Round 2 24:23<23:52.64>
Round 3 24:50<24:50.21>
Round 1 23:47<22:32.69>
Round 2 24:23<23:52.64>
Round 3 24:50<24:50.21>
昨天跑步 三圈都斷斷續續....導至時間上比較慢
但身體的感受是 平均心跳拉高了、每圈時間上來看、差距越來越小<代表進步了>
公司同事水牛哥說上次太魯閣跑2:18m、地勢上又是山路...
可想而知還差一大截、要加緊努力了!跑步訓練有氧最快..
跑二個月下來、這幾次騎車出去、也發現齒比越重了、但是肌力上還是不足
ps:昨天跑完有酸痛...心中很亢奮!^^
標籤:
Run
2012年1月31日 星期二
javascript 畫三角形
許久不見的三角形
for(var i=0;i<10;i++){
for(var d=0;d < 10-i;d++){
document.write(" ");
}
for(var k=0;k<2*i-1;k++){
document.write("★");
}
document.write("<br/>");
}
var c=2
for(var i=9;i>0;i--){
for(var k=0;k<c;k++){
document.write(" ");
}
for(var k=0;k<2*i-3;k++){
document.write("☆");
}
c++;
document.write("<br/>");
}
標籤:
JavaScript
2012年1月18日 星期三
Ibatis+Spirng配置
1.properties //dblink實際參數
2.dblink 配合properties
3.讀取sqlmapconfig
4.java 讀取dao
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="classpath:專案目錄/spring.properties" />
</bean>
2.dblink 配合properties
<bean id="testDataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="${test_driverClassName}" />
<property name="url" value="${test_url}" />
<property name="username" value="${test_username}" />
<property name="password" value="${test_password}" />
<property name="testWhileIdle" value="true"/>
<property name="validationQuery" value="select 1 from dual"/>
<property name="logAbandoned" value="true"/>
<property name="removeAbandoned" value="true"/>
<property name="removeAbandonedTimeout" value="3600"/>
<property name="maxWait" value="20"/>
<property name="maxIdle" value="10"/>
<property name="maxActive" value="-1"/>
<property name="accessToUnderlyingConnectionAllowed" value="true"/>
<bean id="nativeJdbcExtractor" class="org.springframework.jdbc.support.nativejdbc.CommonsDbcpNativeJdbcExtractor"
lazy-init="true" />
<bean id="oracleLobHandler" class="org.springframework.jdbc.support.lob.OracleLobHandler" lazy-init="true">
<property name="nativeJdbcExtractor">
<ref local="nativeJdbcExtractor" />
</property>
</bean>
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="testDataSource"/>
</bean>
3.讀取sqlmapconfig
<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="configLocation">
<value>classpath:專案目錄/SqlMapConfig.xml</value>
</property>
<property name="transactionConfigProperties">
<props>
<prop key="DefaultAutoCommit">false</prop>
</props>
</property>
<property name="lobHandler">
<ref local="oracleLobHandler" />
</property>
</bean>
4.java 讀取dao
<bean id="sqlMapClientTemplate" class="org.springframework.orm.ibatis.SqlMapClientTemplate">
<property name="sqlMapClient" ref="sqlMapClient" />
<property name="exceptionTranslator">
<bean class="org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator">
<property name="dataSource" ref="dataSource" />
</bean>
</property>
</bean>
<bean id="ibatisDAOProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref bean="transactionManager"/>
</property>
<property name="target">
<ref bean="baseIbatisDao"/>
</property>
<property name="transactionAttributes">
<props>
<prop key="*">PROPAGATION_REQUIRED,-Exception</prop>
</props>
</property>
</bean>
String prototype
網路上找到對於prototype的定義、以下是我從字面翻過來的
"javascript既有對像都只有讀的prototype屬性。
只能為原型添加功能,但不能被賦予不同的原型。
但是定義的對象可以被賦給新的原型。"
常用如下:
String.prototype.trim = function() {
return this.replace(/(^\s*)|(\s*$)/g, "");
}
// 全部取代指定字串
String.prototype.replaceAll = function (str1,str2) {
return this.replace(new RegExp(str1,"gm"),str2);
};
// 移除Array指定筆數
Array.prototype.remove = function (i) {
return this.splice(i,1);
};
標籤:
JavaScript
JavaScript String 多種用法
以下這些在coding的過程滿常需要用到、在這裡做個紀錄
string data="test"
data.******()
.toString()
.length
.charAt()
.lastIndexOf()
.indexof()
.replace()
.split()
.slice(start(略),end((略)) //截斷取出
.fontcolor("Red")
.toLowerCase()
.toUpperCase()
.sub()//上標
.sup() //下標
.link("www.google.com")
.big()
.small()
.bold()
.italics()
.strike()
標籤:
JavaScript
2012年1月13日 星期五
Ireport 中文粗體
將要顯示粗體的中文字(kaiu.ttf)的字體改 Arial Narrow、則在ireport中勾選粗體才有作用
Map
fontsMap.put(new FontKey("Arial Narrow", true, false),
new PdfFont(dir+File.separator+"kaiu.ttf", "Identity-H", true, true, false));
fontsMap.put(new FontKey("標楷體", true, false),
new PdfFont(dir+File.separator+"kaiu.ttf", "Identity-H", true, false, false));//設置字體樣式
exporter.setParameter(JRExporterParameter.FONT_MAP, fontsMap);
標籤:
IReport
2012年1月12日 星期四
ireport [sub report]
1.讀取mainReport
JasperReport jasperReport = JasperCompileManager.compileReport("C:\\Temp\\report2.jrxml");
2.先將sub.jasper讀進來、存放至主要的HashMap mapParameter = new HashMap();
InputStream stream1 = getRequest().getSession().getServletContext().getResourceAsStream("xxxxxxxx_subreport_Net.jasper");
JasperReport netReport = (JasperReport) JRLoader.loadObject(stream1);
//map key 對應subReport Name
mapParameter.put("NET_REPORT", netReport);
3.subReport 資料型態 JRMapCollectionDataSource(ArrayList<HashMap>)<
在此命 為NetProduct>後續irport會用
放置mapParameter.put("Report_Net_list", NetProduct());
4.JasperPrint jasperPrint = JasperFillManager.fillReport( jasperReport, a,new JREmptyDataSource());
new JREmptyDataSource也是實作implements JRDataSource 、
如果沒有JRDataSource、null值必需塞new JREmptyDataSource不能放置null或空值
5.iReport設置
(1)新增(NET_REPORT)parameter:net.sf.jasperreports.engine.JasperReport
用意在於java先讀取jaxml或jasper檔在傳給ireport
(2)新增(Report_Net_list)Parameter:net.sf.jasperreports.engine.data.JRMapCollectionDataSource

(2)Expression class :net.sf.jasperreports.engine.JasperReport
Data Source Expression:放置之前java設置的Report_Net_list( JRMapCollectionDataSource)
附上test Code &JAR檔

標籤:
IReport
jQuery ajax方式
var params = {
keyValue : '對應GetDateTagKey',
inputValue : '輸入值'};
var url = '../tag/getDataTag.action';
jQuery.ajax({
type:"POST",
dataType:"json",
async:false, // true:異步,false:同步
url:url,//目標url
data:params,//也可綁定action
beforeSend:function(){},//送出前執行
success:function(json){
var data = eval(json);
if(data != null){
custType.options.length = 0;
for(var i = 0 ; i < data.length ; i++){
custType.options[i] = new Option(data[i].dscr, data[i].lookup_code);
}
}else{
alert("取得失敗");
}
},
error:function(){
alert("取得異常");
}
});
標籤:
Jquery
訂閱:
意見 (Atom)





