控件名
.value
控件名
.value
控件名
[i].checked??? .value?
for each ob in
控件名
?? if ob.checked then ?? ???window.alert ob.value next
控件名
.checked??? .value
Select 1
Select 3
Select 2
Select 1
Select 2
Select 3
Select 4
Select 1
Select 2
Select 3
Select 4
? ??
單行
??????? ?
多行
????? ???
多選
添加選項
ExpList.add(new Option("New Option","3"));
刪除選項
ExpList.remove(ExpList.selectedIndex);
設置當前選項位置
ExpList.selectedIndex=ExpList.length-1;
循環整個選項
并判斷是否被選擇
for(i=0;i<ExpList.options.length;i++) { ? if(ExpList.options[i].selected){ ???? //ExpList.options[i].text; ???? //ExpList.options[i].value; ? } }
單個選項的值
ExpList.options[i].text; ExpList.options[i].value;
<span id="SomePlace1"></span> <div id="SomePlace1"></div>
重新設計包含的
html
SomePlace1.innerHTML="
任意
html
字符串
"
讓該空間的內容消失
SomePlace1.style.display="none";
讓該空間的內容顯示
SomePlace1.style.display="block";
鼠標滑過出現提示
title="Help"
<input type="hidden" name="MyValueName" value="123">
控件名
.value
跟隨事件Event(聲明方式特殊)
<div id=hello1 style=position:absolute>太過分了!吃飯不叫我</div> <SCRIPT for=document EVENT=onmousemove> document_onmousemove(); function document_onmousemove() { ? hello1.style.left=event.x+10; ? hello1.style.top=event.y+10; } </SCRIPT>
<返回>
2.讓TextArea自動換行
? 使用TextArea的Wrap屬性
ASP中手動換行用: replace(rs("A"),"</br>", VBCRLF) str=request.querystring("text1") str=Replace(str, Chr(32), " ") '把空格換成 標志 str=Replace(str, vbCrLf, "<br>") '把回車換行符換成<br>標志 調出時再轉過來就好了<返回> 3.讓TextArea支持Table鍵 <SCRIPT LANGUAGE="JavaScript"> <!-- function testTab() { ?? var sel = document.selection.createRange(); ?? var mytext= sel.text; ?? var i,j,k; ?? if (event.shiftKey && event.keyCode == 9) ?? { ????? arr=mytext.split(String.fromCharCode(13,10)) ????? mytext="" ????? for(k=0;k<arr.length;k++) ????? { ???????? for (j=1; j<=4;j++) ???????? { ??????????? if(arr[k].substr(0,1)=="\u0020") ??????????? { ?????????????? arr[k]=arr[k].slice(1) ??????????? } ???????? } ???????? mytext += arr[k] + ((k==(arr.length-1))? "" : String.fromCharCode(13,10)); ????? } ????? with(sel){ ???????? sel.text = mytext; ???????? collapse(true) ???????? moveEnd("character",0) ???????? moveStart("character",(mytext.length ) * -1) ???????? select() ????? } ????? window.event.cancelBubble = true; ????? event.returnValue = false; ????? return; ?? } ?? if (event.keyCode == 9) ?? { ????? arr=mytext.split(String.fromCharCode(13,10)) ????? mytext="" ????? for(j=0;j<arr.length;j++) ????? { ???????? mytext += "\u0020\u0020\u0020\u0020" + arr[j] + ((j==(arr.length-1))? "" : String.fromCharCode(13,10)); ????? } ????? with(sel){ ???????? sel.text = mytext; ???????? collapse(true) ???????? moveEnd("character",0) ???????? moveStart("character",(mytext.length -4) * -1) ???????? select() ????? } ????? window.event.cancelBubble = true; ????? event.returnValue = false; ????? return; ?? } } //--> </SCRIPT><返回> 4.復制數據到剪貼板 ?JM_cc(txt) ?window.clipboardData.setData("Text", txt); ?global.focus(); ?document.execCommand('Paste'); ?window.clipboardData.setData("Text", old); <返回> 5.得到當前選中的文本 var sel = document.selection.createRange(); var mytext= sel.text;? //當前選中的文本 var e = event.srcElement;? //設置文本為選中 var r =e.createTextRange(); r.moveStart('character',e.value.length); r.collapse(true); r.select();<返回> 6.客戶端腳本的基本對象
<返回>
7.保護自己編寫的HTML和腳本的方法
? (1). oncontextmenu="window.event.returnValue=false" 將徹底屏蔽鼠標右鍵 ??? <table border oncontextmenu=return(false)><td>no</table> 可用于Table ? (2). <body onselectstart="return false"> 取消選取、防止復制 ? (3). onpaste="return false" 不準粘貼 ? (4). oncopy="return false;" oncut="return false;" 防止復制 ? (5). 防止被人frame ????? <SCRIPT LANGUAGE=JAVASCRIPT><!-- ???????? if (top.location != self.location)top.location=self.location; ?????? // --> ????? </SCRIPT> ? (6). 永遠都會帶著框架 ???? <script language="JavaScript"><!-- ??????? if (window == top)top.location.href = "frames.htm"; //frames.htm為框架網頁 ???? // --></script> ? (7).網頁將不能被另存為 ???? <noscript><iframe src=*.html></iframe></noscript> <返回> 8.IE地址欄前換成自己的圖標 ?<link rel="Shortcut Icon" href="favicon.ico"> <返回> 9.可以在收藏夾中顯示出你的圖標 ?<link rel="Bookmark" href="favicon.ico"> <返回> 10.關閉輸入法 ?<input style="ime-mode:disabled"> <返回> 11.直接查看源代碼 ? ?<input type=button value=查看網頁源代碼 onclick="window.location = 'view-source:'+ 'http://www.csdn.net/'"><返回> 12.在Javascript中定義一個對象(屬性,方法) function pasta(grain, width, hasEgg) { ??? this.grain = grain; ??? this.width = width; ??? this.hasEgg = hasEgg; ??? this.toString = pastaToString; } function pastaToString() { ??? return "Grain: " + this.grain + "\n" + "Width: " + this.width + "\n" + "Egg?: " + Boolean(this.hasEgg); } var P1=new pasta(3,3,false);<返回> 13. 取得控件的絕對位置 //Javascript <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><返回> 14. 光標是停在文本框文字的最后 <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()"><返回> 15. 判斷上一頁的來源 asp: ? request.servervariables("HTTP_REFERER") javascript: ? document.referrer<返回> 16. 最小化、最大化、關閉窗口 <object id=hh1 classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11"> <param name="Command" value="Minimize"></object> <object id=hh2 classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11"> <param name="Command" value="Maximize"></object> <OBJECT id=hh3 classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11"> <PARAM NAME="Command" VALUE="Close"></OBJECT> <input type=button value=最小化 onclick=hh1.Click()> <input type=button value=最大化 onclick=hh2.Click()> <input type=button value=關閉 onclick=hh3.Click()> 本例適用于IE<返回> 17. 檢查一段字符串是否全由數字組成 <script language="Javascript"><!-- function checkNum(str){return str.match(/\D/)==null} // --></script><返回> 18. 獲得一個窗口的大小 document.body.clientWidth,document.body.clientHeight<返回> 19. 怎么判斷是否是字符 if (/[^\x00-\xff]/g.test(s)) ? alert("含有漢字"); else ? alert("全是字符");<返回> 20. 檢測某個網站的鏈接速度 把如下代碼加入<body>區域中: <script language=Javascript> tim=1 setInterval("tim++",100) b=1 var autourl=new Array() autourl[1]="www.njcatv.net" autourl[2]="javacool.3322.net" autourl[3]="www.sina.com.cn" autourl[4]="www.nuaa.edu.cn" autourl[5]="www.cctv.com" function butt(){ ?? document.write("<form name=autof>") ?? for(var i=1;i<autourl.length;i++) ????? document.write("<input type=text name=txt"+i+" size=10 value=測試中……> =》<input type=text name=url"+i+" size=40> =》<input type=button value=GO onclick=window.open(this.form.url"+i+".value)><br/>") ?? document.write("<input type=submit value=刷新></form>") } butt() function auto(url){ ?? document.forms[0]["url"+b].value=url ?? if(tim>200) ?? { ????? document.forms[0]["txt"+b].value="鏈接超時" ?? } ?? else ?? { ????? document.forms[0]["txt"+b].value="時間"+tim/10+"秒" ?? } ?? b++ } function run() { ?? for(var i=1;i<autourl.length;i++) ????? document.write("<img src=http://"+autourl[i]+"/"+Math.random()+" width=1 height=1 onerror=auto('http://"+autourl[i]+"')>") } run()</script><返回> 21. 各種樣式的光標 auto :標準光標 default :標準箭頭 hand :手形光標 wait :等待光標 text :I形光標 vertical-text :水平I形光標 no-drop :不可拖動光標 not-allowed :無效光標 help :?幫助光標 all-scroll :三角方向標 move :移動標 crosshair :十字標 e-resize n-resize nw-resize w-resize s-resize se-resize sw-resize<返回> 22.讓TEXTAREA自適應文字的行數 <textarea rows=1 name=s1 cols=27 onpropertychange="this.style.posHeight=this.scrollHeight"></textarea><返回> 23. 日期減去天數等于第二個日期 <script language=Javascript> function cc(dd,dadd) { //可以加上錯誤處理 ?? var a = new Date(dd) ?? a = a.valueOf() ?? a = a - dadd * 24 * 60 * 60 * 1000 ?? a = new Date(a) ?? alert(a.getFullYear() + "年" + (a.getMonth() + 1) + "月" + a.getDate() + "日") } cc("12/23/2002",2) </script><返回> 24. 選擇了哪一個Radio <HTML> <script language="vbscript"> function checkme() ?? for each ob in radio1 ?? if ob.checked then ????? window.alert ob.value ?? next end function </script> <BODY> <INPUT name="radio1" type="radio" value="style" checked>Style <INPUT name="radio1" type="radio" value="barcode">Barcode <INPUT type="button" value="check" onclick="checkme()"> </BODY></HTML><返回> 25.獲得本頁url的request.servervariables("")集合 Response.Write "<TABLE border=1><!-- Table Header --><TR><TD><B>Variables</B></TD><TD><B>Value</B></TD></TR>" for each ob in Request.ServerVariables ?? Response.Write "<TR><TD>"&ob&"</TD><TD>"&Request.ServerVariables(ob)&"</TD></TR>" next Response.Write "</TABLE>"<返回> 26.ENTER鍵可以讓光標移到下一個輸入框 <input onkeydown="if(event.keyCode==13)event.keyCode=9"><返回> 28.引用其他網頁 <table width=100% border="0"><tr><td><script language="JavaScript" location="http://91down.7161.net" id="nd91down" src="http://91down.7161.net/js/new1-1.htm"></script></td><td><script language="JavaScript" location="http://91down.7161.net" id="nd91down" src="http://91down.7161.net/js/new1-2.htm"></script></td></tr></table><返回> 29.常用的正則表達式 匹配中文字符的正則表達式: [\u4e00-\u9fa5] 匹配雙字節字符(包括漢字在內):[^\x00-\xff] 匹配空行的正則表達式:\n[\s| ]*\r 匹配HTML標記的正則表達式:/<(.*)>.*<\/\1>|<(.*) \/>/ 匹配首尾空格的正則表達式:(^\s*)|(\s*$) 匹配Email地址的正則表達式:\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)* 匹配網址URL的正則表達式:http://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?(1)應用:計算字符串的長度(一個雙字節字符長度計2,ASCII字符計1) ???????? ??? String.prototype.len=function(){return this.replace([^\x00-\xff]/g,"aa").length;}(2)應用:javascript中沒有像vbscript那樣的trim函數,我們就可以利用這個表達式來實現 ?? String.prototype.trim = function() ?? { ????? return this.replace(/(^\s*)|(\s*$)/g, ""); ?? }(3)應用:利用正則表達式分解和轉換IP地址 ?? function IP2V(ip) //IP地址轉換成對應數值 ?? { ????? re=/(\d+)\.(\d+)\.(\d+)\.(\d+)/g //匹配IP地址的正則表達式 ????? if(re.test(ip)) ????? { ???????? return RegExp.$1*Math.pow(255,3))+RegExp.$2*Math.pow(255,2))+RegExp.$3*255+RegExp.$4*1 ????? } ????? else ????? { ???????? throw new Error("Not a valid IP address!") ????? } ?? }(4)應用:從URL地址中提取文件名的javascript程序 ?? s="http://www.9499.net/page1.htm"; ?? s=s.replace(/(.*\/){0,}([^\.]+).*/ig,"$2") ; //Page1.htm(5)應用:利用正則表達式限制網頁表單里的文本框輸入內容 ?? 用正則表達式限制只能輸入中文:onkeyup="value=value.replace(/[^\u4E00-\u9FA5]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\u4E00-\u9FA5]/g,''))" ?? 用正則表達式限制只能輸入全角字符: onkeyup="value=value.replace(/[^\uFF00-\uFFFF]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\uFF00-\uFFFF]/g,''))" ?? 用正則表達式限制只能輸入數字:onkeyup="value=value.replace(/[^\d]/g,'') "onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))" ?? 用正則表達式限制只能輸入數字和英文:onkeyup="value=value.replace(/[\W]/g,'') "onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))" <返回> 30.彈出來提示對話框 window.showModalDialog(url); <返回> 31.取得查詢字符串,然后就生成成對的數組 var argstr = window.top.location.search.substring(1,window.top.location.search.length); var args = argstr.split('&'); <返回> 32.另類的onload函數 <SCRIPT FOR=window event=onload> try { ? Start(); } catch (exception) { } </script><返回> 33.取得IE的版本 var ieVer = parseFloat(navigator.appVersion.substring(navigator.appVersion.indexOf("MSIE ")+5, navigator.appVersion.length)) var isIE6 = ieVer >= 6.0<返回> 34.提交表單 // aimForm 為表單名??? aimPage為提交到的頁 //提交表單到新建的網頁 function SubmitFormToNewPage(aimForm,aimPage){ ?? aimForm.method="POST"; ?? aimForm.target="_blank"; ?? aimForm.action=aimPage; ?? aimForm.submit(); } //在本地提交表單 function SubmitFormToLocalPage(aimForm,aimPage){ ?? aimForm.method="POST"; ?? aimForm.target="_self"; ?? aimForm.action=aimPage; ?? aimForm.submit(); }<返回> 35.判斷是否是整數 function IsNum(s)? //整數 { ?? if(s=="null"||s=="undefined"||s.length<1) ????? return false; ?? if(isNaN(parseInt(s))) ????? return false; ?? else ?? if((parseInt(s)+"").length!=s.length) ????? return false; ?? else ????? return true; } function IsNumber(JudgeNum){? //判斷大于0的數 ?? var JudgeStr=JudgeNum.toString(); ?? for (var i=0;i<JudgeStr.length;i++) { ????? var oneChar=JudgeStr.charAt(i); ????? if (oneChar<"0" || oneChar >"9"){ ???????? return false; ????? } ?? } ?? return true; }<返回> 36.鏈接css文件和js文件 <link rel="stylesheet" href="../css/style.css" type="text/css"> <script language="javascript" src="../includes/jslib.js" ></script><返回> 37.引用框架的內容 window.top.frames["mainFrame"].location.href=s; 在IFRAME標簽中引用框架的內容 parent.frames["mainFrame"].location.href 在窗口中引用IFrame中的內容 window.top.frames["mainFrame"].confFrame.location.href<返回> 38.打開沒有最大化按鈕的窗口 window.open("http://www.google.com","","width=250,height=220,scrollbars=no,resizable=no,center=yes");<返回> 39.在頁面上顯示一個有邊框的Frame <fieldset style="width:500;height:100"> <legend>標題</legend> 具體內容 </fieldset><返回> 40.判斷日期1是不是大于日期2 function IsDate1AfterThanDate2 (year1,month1,day1,year2,month2,day2){ ?? var iFrom=Date.parse(month1+"-"+day1+"-"+year1); ?? var iTo=Date.parse(month2+"-"+day2+"-"+year2); ?? if(iFrom>iTo) ????? return true; ?? else ????? return false; } function IsDate(year,month,day){ ?? if( (!IsNumber(year))||(year.length!=4)) ????? return false; ?? if( (!IsNumber(month))||(month>12)||(month<1) ) ????? return false; ?? if( (!IsNumber(day))||(day>31)||(day<1) ) ????? return false; ?? var myDate=new Date(); ????? myDate.setFullYear(year,month-1,day); ?? if (isNaN(myDate.getFullYear())){ ????? return false; ?? } ?? else{ ????? if( (myDate.getFullYear()!=year)||(myDate.getDate()!=day)||(myDate.getMonth()!=(month-1).toString()) ) ???????? return false; ?? } ????? return true; } function IsNumber(JudgeNum){ ?? var JudgeStr=JudgeNum.toString(); ?? for (var i=0;i<JudgeStr.length;i++) { ????? var oneChar=JudgeStr.charAt(i); ????? if (oneChar<"0" || oneChar >"9"){ ???????? return false; ????? } ?? } ?? return true; }<返回> 41.常用的Javascript內建類的方法
對象
方法或屬性
意義
例子
Array
length
表示數組大小,也可以通過該屬性動態調整數組大小。設置可以不調整它直接擴大數組。
var theMonths = new Array(12); theMonths[0] = "Jan"; theMonths[1] = "Feb"; theMonths[2] = "Mar"; theMonths[20] = "12";
concat
把兩個數組合并
a = new Array(1,2,3); b = new Array(4,5,6); a = a. concat(b)
join
把數組變為字符串
?? a = new Array(0,1,2,3,4); ?? b = a.join("-");
Date
Date.parse(dateVal)
將日期轉為數字,用于比較兩個日期的大小。
dateVal
格式為
month+day+year
iFrom=Date.parse(“10-1-2004”);
setFullYear (year,month-1,day)
用于判斷
3
個字符串合起來是不是日期或者判斷該天是不是存在。這里
month
從
0
開始,故和實際值差
1
myDate.setFullYear(year,month-1,day); if (isNaN(myDate.getFullYear())){ ????? return false; } else{ ? if( (myDate.getFullYear()!=year)|| ????? (myDate.getDate()!=day)|| ????? (myDate.getMonth()!=(month-1) ) ????? return false;? }
Date()
獲得當前時間
d = new Date();??????????????????????????
Global
(全局類,引用方法可以不要帶
Global.
)
isNaN
當從字符到日期轉換失敗,或者從字符到數字轉換失敗,都返回
NaN
。用
isNaN
可以判斷返回值是不是
NaN
?
parseInt
將字符串轉換為整數,轉換失敗返回
NaN
或者盡量轉換。所以用它來判斷是不是數字,還要加上判斷轉化后長度是不是一樣
parseInt("abc")???? //
返回
NaN
。
parseInt("12abc")?? //
返回
12
。
parseInt("12")?? //
返回
12
parseFloat
轉為實數
?
String
主要函數和
Java
或者
C
#一樣
replace
替代某個字符。如果僅替代一個和
C
#一樣,如果要替代全部某字符,就得用到了匹配串
? re=/#/g; ? str=str.replace(re,"<br>");
? 把#用
<br>
代替
split
將某個字符串按指定間隔符分割
var s = "The rain in Spain"; ss = s.split(" ");? //ss
是一個數組
<返回>
42.如何在另一個窗體
對原來窗體進行操作
? 在打開的新窗體,用window.opener來訪問原來窗體的對象。例如? alert(window.opener.hiddens.value); ? 可以對層進行重寫Html代碼,例如 window.opener.divStatus.innerHTML="Proctored"; ?<返回> 43.層的隱藏與顯示 ?? 只要設置層的style的display屬性即可。 比如<div style="display:none" id="divTest">隱藏的層</div> ?? 如果要顯示它可以通過腳本來控制。例如divTest.style.display = "";? 或者? window.document.getElementById("MyDiv").style.display = "";<返回> 44.禁止右鍵 <body oncontextmenu="return false"><返回> 45.得到當前顯示器的分辨率 window.srceen.width 得到屏幕的寬度 window.srceen.height 得到屏幕的高度<返回> 46.定時運行特定代碼 setTimeout(Code,Timeout);?? 是從現在算起多少微秒后運行該代碼(只運行一次) setInterval(Code,Timeout);? 是每隔多少微秒運行一次代碼 Code是一段字符串,里邊是js代碼,Timeout是時間間隔,單位是微秒 <input name="txtTimer" value="10秒"> <SCRIPT LANGUAGE=javascript> <!-- ??? waitTime=10000; //10 秒 ??? timer=setInterval("OnTimer()",1000); ??? function OnTimer(){ ??????? waitTime=waitTime-1000; ??????? if(waitTime==0){ ??????????? window.close(); ??????? } ??????? txtTimer.value=waitTime/1000+"秒"; ??? } //--> </SCRIPT><返回> 47.得到本頁網址 var Url = window.location.href;<返回> 48.保存當前頁面的內容 document.execCommand("SaveAs","","C:\\index.htm");<返回> 49.用模式窗體,打開一個參數獲取窗體 主窗體中用 ?? var returnvalue=window.showModalDialog('../webPri/GetDate.asp',frmApplyPriItem,"status=no; help=no; dialogWidth=320px; dialogHeight=120px;"); 子窗體中用 ?? window.returnValue="OK"; ?? window.dialogArguments.FormObject.value<返回> 50.Web打印文檔 <!--語言無關 保存成 .HTML--> <html> <head> <meta name=vs_targetSchema content="http://schemas.microsoft.com/intellisense/ie5"> <title>網絡打印模板頁</title> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <!--media=print 這個屬性可以在打印時有效--> <style media=print> .Noprint{display:none;} .PageNext{page-break-after: always;} </style> <style> .tdp { border-bottom: 1 solid #000000; border-left: 1 solid #000000; border-right: 0 solid #ffffff; border-top: 0 solid #ffffff; } .tabp { border-color: #000000 #000000 #000000 #000000; border-style: solid; border-top-width: 2px; border-right-width: 2px; border-bottom-width: 1px; border-left-width: 1px; } .NOPRINT { font-family: "宋體"; font-size: 9pt; } </style> </head> <body > <center class="Noprint" > <p> <OBJECT id=WebBrowser classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 width=0> </OBJECT> <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)> <br/> </p> <hr align="center" width="90%" size="1" noshade> </center> <table width="90%" border="0" align="center" cellpadding="2" cellspacing="0" class="tabp"> <tr> <td colspan="3" class="tdp">第1頁</td> </tr> <tr> <td width="29%" class="tdp"> </td> <td width="28%" class="tdp"> </td> <td width="43%" class="tdp"> </td> </tr> <tr> <td colspan="3" class="tdp"> </td> </tr> <tr> <td colspan="3" class="tdp"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="50%" class="tdp"><p>這樣的報表</p> <p>對一般的要求就夠了。</p></td> <td> </td> </tr> </table></td> </tr> </table> <hr align="center" width="90%" size="1" noshade class="NOPRINT" > <!--分頁--> <div class="PageNext"></div> <table width="90%" border="0" align="center" cellpadding="2" cellspacing="0" class="tabp"> <tr> <td class="tdp">第2頁</td> </tr> <tr> <td class="tdp">看到分頁了吧</td> </tr> <tr> <td class="tdp"> </td> </tr> <tr> <td class="tdp"> </td> </tr> <tr> <td class="tdp"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="50%" class="tdp"><p>這樣的報表</p> <p>對一般的要求就夠了。</p></td> <td> </td> </tr> </table></td> </tr> </table> </body> </html> 在基于框架的網頁打印時,用如下函數可以打印某個框架內的網頁 <input type=button onclick="printweb(this)"> <script> function printweb() { ?? this.focus(); ?? window.print(); } </script>