1.鼠標(biāo)移動上去,圖片變亮,移開又變成灰色。改變的是透明度。
<style>
.p1{filter:Alpha(Opacity=20)}
.p2{filter:Alpha(Opacity=100)}
</style>
<img src="/image/xxx.gif" border=0 class=p1 on mouseover="this.classname=p2" on mouseout="this.classname=p1">
2.怎樣在網(wǎng)頁中播放mp3格式音樂
<html>
<title></title>
<body>
<embed src="http://music.jztele.com/mp3/dianying/xyxy.mp3"; loop=false autostart=true name=bgss width="0" height=0>
</body>
</html>
詳細(xì)說明:
<embed
src="xx.mp3" 音樂文件
loop=false 是否重復(fù)播放
autostart=true 是否自動開始
name=bgss 為了控制而設(shè)定的名字
width="0" height="0" 寬、高 >
3.滾動現(xiàn)實公告
<table width="800" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr style="text-align: center;">
<td height="0"> <hr noshade> <p>
<marquee>
<xmp> 事件文字滾動 ——公告</xmp>
</marquee>
</p>
<hr noshade></td>
</tr>
</tbody>
</table>
4.以圖片作為按鈕
<form method="post" action="test.html">
<input type="text" name="textfield">
<input type="text" name="textfield2">
<input type="image" border="0" name="imageField" src="../img/submit.jpg" width="71" height="32" >
</form>
5.表格中單元格之間分隔線的隱藏方法
其實上面的三個表格都有三行三列,隱藏分隔線的訣竅在于rules,察看這三個表格的源代碼,我們可以看到<TABLE>標(biāo)簽中都有rules。 它有三個參數(shù)(cols,rows,none),當(dāng)rules=cols時,表格會隱藏縱向的分隔線,這樣我們就只能看到表格的行;當(dāng)rules=rows時,則 隱藏了橫向的分隔線,這樣我們只能看到表格的列;而當(dāng)rules=none時,縱向分隔線和橫向分隔線將全部隱藏。
6.表格邊框的隱藏
表格邊框的顯示與隱藏,是可以用frame參數(shù)來控制的。請注意它只控制表格的邊框圖,而不影晌單元格。
只顯示上邊框 <table frame=above>
只顯示下邊框 <table frame=below>
只顯示左、右邊框 <table frame=vsides>
只顯示上、下邊框 <table frame=hsides>
只顯示左邊框 <table frame=lhs>
只顯示右邊框 <table frame=rhs>
不顯示任何邊框 <table frame=void>
7.刷新的不同狀態(tài)
非模態(tài)刷新父頁面:window.opener.location.reload();
模態(tài)刷新父頁面:window.dialogArguments.location.reload();
window.location.assign('chklogin.jsp');
window.location.reload('chklogin.jsp');
以后用前者進(jìn)行刷新吧。后者似乎對FF 不怎么兼容。
8.文字過長,縮略顯示為...
<DIV STYLE="width: 120px; border: 1px solid blue;
overflow: hidden; text-overflow:ellipsis">
<NOBR title="就是比如有一行文字,很長,表格內(nèi)一行顯示不下.">就是比如有一行文字,很長,表格內(nèi)一行顯示不下.</NOBR>
</DIV>
9.加入收藏夾通用代碼
<script type="text/javascript">
function addBookmark(title,url)
{
if (window.sidebar)
{
window.sidebar.addPanel(title, url,"");
} else if( document.all )
{
window.external.AddFavorite( url, title);
} else if( window.opera && window.print )
{
return true;
}
}
</script>
頁面使用:<a href=javascript:addBookmark('天極網(wǎng)網(wǎng)頁陶吧','http://homepage.yesky.com/')> 添加到收藏</a>
10.幾種彈出窗口
用戶輸入:var msg=prompt("請輸入密碼:");if(msg == "PKU") 彈出輸入框。
用戶確定:var IsOk = confirm('ok');
警告:alert("對不起");
open為打開一個窗口。
11.動態(tài)改變 下拉列表的值。
document.formname.elements[第幾個元素].text = "test";
eg:
document.test9_1.elements[0].options[0].text="昆明市";
當(dāng)然也可以用,之所以寫出來是因為很多時候,我總是習(xí)慣用value,而忽略了text屬性:
document.getElementById('select').options[0].text="昆明市";
12.動態(tài)插入表格內(nèi)容:
document.getElementById('saleAndLost').rows[1].cells
x[1].innerHTML="test";
13.播放器代碼
(1)media player代碼:
<DIV>
<OBJECT id=videowindow1 height=185 width=179 classid=CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6>
<PARAM NAME="URL" VALUE="http://tyrb.com/big5/site1/images/2006-02/17/020203170937500170795.mp3">
<PARAM NAME="playCount" VALUE="infinite">
<PARAM NAME="autoStart" VALUE="1">
<PARAM NAME="volume" VALUE="50">
<PARAM NAME="uiMode" VALUE="full">
<PARAM NAME="stretchToFit" VALUE="1">
</OBJECT>
</DIV>
其中http://tyrb.com/big5/site1/images/2006-02/17/020203170937500170795.mp3就是歌曲"幸福像花兒一樣"的地址,
改變這個地址也就改變了你的歌曲
(2)WMP播放器
<embed src="影音文件地址" width="播放器寬" height="播放器高" autostart="true" loop="true" align="center" volume="200" type="audio/x-pn-realaudio-plugin" exts="ra,ram" Init fn="load-types" mime-types="mime.types" ALT="(Random)"></embed>
(3)Flash播放器
<embed src="Flash地址" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="播放器寬" height="播放器高[" quality="High"></embed>
(4)RealPlayer播放器
<object classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" width="480" height="360">
<param name="src" value="dfA.rmvb" />
<param name="controls" value="ImageWindow" />
<param name="console" value="_master" />
</object><br />
<object classid="CLSID:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA" width="480" height="32">
<param name="src" value="dfA.rmvb" />
<param name="controls" value="controlpanel" />
<param name="AUTOSTART" value="1">
<param name="console" value="_18c03c83e52df1f1285b0ac2d1ea7911" />
</object>
14.window.open參數(shù)詳解
(1). 使用舉例:
<SCRIPT LANGUAGE="javascript">
<!--
window.open ('page.html', 'newwindow', 'height=100, width=400, top=0, left=0, toolbar=no, menubar=no, scrollbars=no,resizable=no,location=no, status=no')
//寫成一行
-->
</SCRIPT>
(2). 參數(shù)詳細(xì)描述
'page.html' 彈出窗口的文件名;
'newwindow' 彈出窗口的名字(不是文件名),非必須,可用空''代替;
height=100 窗口高度;
width=400 窗口寬度;
top=0 窗口距離屏幕上方的象素值;
left=0 窗口距離屏幕左側(cè)的象素值;
toolbar=no 是否顯示工具欄,yes為顯示;
menubar,scrollbars 表示菜單欄和滾動欄。
resizable=no 是否允許改變窗口大小,yes為允許;
location=no 是否顯示地址欄,yes為允許;
status=no 是否顯示狀態(tài)欄內(nèi)的信息(通常是文件已經(jīng)打開),yes為允許;
1 網(wǎng)頁中所有鏈接去除下劃線:
<style type="text/css">
<!--
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: none;
}
a:active {
text-decoration: none;
}
-->
</style>
2在當(dāng)前頁面定位
<html>
<head></head>
<body>
<a href="#first">one</a>
<a href="#two">two</a>
<a href="#three">three</a>
<a name="first"><h1>one</h1>
<p> firstfirstfirstfirst
<br>
<br><br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br>
firstfirstfirstfirstfirst
</p><br/>
<a name="two"><h1>two</h1>
<p> twotwotwotwotwotwotwo
<br><br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br><br>
twotwotwotwotwotwotwotwotwo
</p><br/>
<a name="three"><h1>three</h1>
<p> threethreethreethreethree
<br><br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br>
threethreethreethreethree
<br>
3 Frame
<frameset cols="50,400">
<frame src="div.html">
<frame src="about:blank">
</frameset>
////////////////////////////////////
<html>
<frameset rows="15%,*">
<frame src="top.html" noresize>
<frameset cols="30%,*">
<frame src="left.html" scrolling=yes>
<frame src="right1.html">
</frameset>
<noframes>
<body>
<p>你好啊</p>
</body>
</noframes>
</frameset>
</html>
4 自己寫過的
<%@ page language="java" pageEncoding="GBK"
c%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean"
prefix="bean"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html"
prefix="html"%>
<html>
<head>
<title>JSP for RegisterForm form</title>
<script language="javascript">
<!--
function check()
{ var name=document.ReForm.name.value;
var pass=document.ReForm.password.value;
var repass=document.ReForm.repassword.value;
var email=document.ReForm.email.value;
//驗證數(shù)據(jù)的合法性
if (!name||name.replace(/\s/g,"")=="")
{ alert("用戶名不能為空或空格,請輸入用戶名!");
ReForm.name.focus();
return false;
}
if (!pass||pass.replace(/\s/g,"")=="")
{
alert("用戶密碼不能為空或空格,請輸入密碼!");
ReForm.password.focus();
return false;
}
if (!repass||repass.replace(/\s/g,"")=="")
{ alert("用戶確認(rèn)密碼不能為空或空格,請輸入密碼!");
ReForm.repassword.focus();
return false;
}
if (pass != repass)
{ alert("密碼與確認(rèn)密碼不同");
ReForm.password.focus();
return false;
}
if (!email||email.replace(/\s/g,"")=="")
{
alert("請輸入Email且不能為空格!");
ReForm.email.focus();
return false;
}
if (!(email.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1))
{ alert("請輸入合法的Email!");
ReForm.email.focus();
return false;
}
}
//-->
</script>
</head>
<body>
<center>
<html:form action="/register" method="post" focus="name">
name : <html:text property="name" />
<br />
password : <html:password property="password" />
<br />
repassword : <html:password property="repassword" />
<br />
sex:<html:radio property="sex" value="1" >男</html:radio><html:radio property="sex" value="0">女</html:radio>
<br />
like:
<html:multibox property="array" value="bc"></html:multibox>編程
<html:multibox property="array">lq</html:multibox>籃球<br/>
email : <html:text property="email" />
<br/>
<html:submit >注冊</html:submit>
<html:reset>取消</html:reset>
</html:form>
</center>
</body>
</html>
5常用的正則表達(dá)式
if(days.search("^[0-9]*[1-9][0-9]*$")!=0)
{
alert("請輸入整數(shù)");
apply_HolidayForm.days.value="";
apply_HolidayForm.days.focus();
return false;
}
if(days.search("^[0-9]*[1-9][0-9]*$")!=0)
{
alert("請輸入整數(shù)");
apply_HolidayForm.days.value="";
apply_HolidayForm.days.focus();
return false;
}
^\d+$ //匹配非負(fù)整數(shù)(正整數(shù) + 0)
^[0-9]*[1-9][0-9]*$ //匹配正整數(shù)
^((-\d+)|(0+))$ //匹配非正整數(shù)(負(fù)整數(shù) + 0)
^-[0-9]*[1-9][0-9]*$ //匹配負(fù)整數(shù)
^-?\d+$ //匹配整數(shù)
^\d+(\.\d+)?$ //匹配非負(fù)浮點數(shù)(正浮點數(shù) + 0)
^(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*))$ //匹配正浮點數(shù)
^((-\d+(\.\d+)?)|(0+(\.0+)?))$ //匹配非正浮點數(shù)(負(fù)浮點數(shù) + 0)
^(-(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*)))$ //匹配負(fù)浮點數(shù)
^(-?\d+)(\.\d+)?$ //匹配浮點數(shù)
^[A-Za-z]+$ //匹配由26個英文字母組成的字符串
^[A-Z]+$ //匹配由26個英文字母的大寫組成的字符串
^[a-z]+$ //匹配由26個英文字母的小寫組成的字符串
^[A-Za-z0-9]+$ //匹配由數(shù)字和26個英文字母組成的字符串
^\w+$ //匹配由數(shù)字、26個英文字母或者下劃線組成的字符串
^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$ //匹配email地址
^[a-zA-z]+://匹配(\w+(-\w+)*)(\.(\w+(-\w+)*))*(\?\S*)?$ //匹配url
匹配中文字符的正則表達(dá)式: [\u4e00-\u9fa5]
if(value.search("[\u4e00-\u9fa5]")==0){
alert("類型名不能為中文!");
return false;
}
if(value.search("[\u4e00-\u9fa5]")==0){
alert("類型名不能為中文!");
return false;
}
匹配雙字節(jié)字符(包括漢字在內(nèi)):[^\x00-\xff]
匹配空行的正則表達(dá)式:\n[\s| ]*\r
匹配HTML標(biāo)記的正則表達(dá)式:/<(.*)>.*<\/>|<(.*) \/>/
匹配首尾空格的正則表達(dá)式:(^\s*)|(\s*$)
匹配Email地址的正則表達(dá)式:\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*
匹配網(wǎng)址URL的正則表達(dá)式:^[a-zA-z]+://(\w+(-\w+)*)(\.(\w+(-\w+)*))*(\?\S*)?$
匹配帳號是否合法(字母開頭,允許5-16字節(jié),允許字母數(shù)字下劃線):^[a-zA-Z][a-zA-Z0-9_]{4,15}$
匹配國內(nèi)電話號碼:(\d{3}-|\d{4}-)?(\d{8}|\d{7})?
匹配騰訊QQ號:^[1-9]*[1-9][0-9]*$
下表是元字符及其在正則表達(dá)式上下文中的行為的一個完整列表:
\ 將下一個字符標(biāo)記為一個特殊字符、或一個原義字符、或一個后向引用、或一個八進(jìn)制轉(zhuǎn)義符。
^ 匹配輸入字符串的開始位置。如果設(shè)置了 RegExp 對象的Multiline 屬性,^ 也匹配 ’\n’ 或 ’\r’ 之后的位置。
$ 匹配輸入字符串的結(jié)束位置。如果設(shè)置了 RegExp 對象的Multiline 屬性,$ 也匹配 ’\n’ 或 ’\r’ 之前的位置。
* 匹配前面的子表達(dá)式零次或多次。
+ 匹配前面的子表達(dá)式一次或多次。+ 等價于 {1,}。
? 匹配前面的子表達(dá)式零次或一次。? 等價于 {0,1}。
{n} n 是一個非負(fù)整數(shù),匹配確定的n 次。
{n,} n 是一個非負(fù)整數(shù),至少匹配n 次。
{n,m} m 和 n 均為非負(fù)整數(shù),其中n <= m。最少匹配 n 次且最多匹配 m 次。在逗號和兩個數(shù)之間不能有空格。
? 當(dāng)該字符緊跟在任何一個其他限制符 (*, +, ?, {n}, {n,}, {n,m}) 后面時,匹配模式是非貪婪的。非貪婪模式盡可能少的匹配所搜索的字符串,而默認(rèn)的貪婪模式則盡可能多的匹配所搜索的字符串。
. 匹配除 "\n" 之外的任何單個字符。要匹配包括 ’\n’ 在內(nèi)的任何字符,請使用象 ’[.\n]’ 的模式。
(pattern) 匹配pattern 并獲取這一匹配。
(?:pattern) 匹配pattern 但不獲取匹配結(jié)果,也就是說這是一個非獲取匹配,不進(jìn)行存儲供以后使用。
(?=pattern) 正向預(yù)查,在任何匹配 pattern 的字符串開始處匹配查找字符串。這是一個非獲取匹配,也就是說,該匹配不需要獲取供以后使用。
(?!pattern) 負(fù)向預(yù)查,與(?=pattern)作用相反
x|y 匹配 x 或 y。
[xyz] 字符集合。
[^xyz] 負(fù)值字符集合。
[a-z] 字符范圍,匹配指定范圍內(nèi)的任意字符。
[^a-z] 負(fù)值字符范圍,匹配任何不在指定范圍內(nèi)的任意字符。
\b 匹配一個單詞邊界,也就是指單詞和空格間的位置。
\B 匹配非單詞邊界。
\cx 匹配由x指明的控制字符。
\d 匹配一個數(shù)字字符。等價于 [0-9]。
\D 匹配一個非數(shù)字字符。等價于 [^0-9]。
\f 匹配一個換頁符。等價于 \x0c 和 \cL。
\n 匹配一個換行符。等價于 \x0a 和 \cJ。
\r 匹配一個回車符。等價于 \x0d 和 \cM。
\s 匹配任何空白字符,包括空格、制表符、換頁符等等。等價于[ \f\n\r\t\v]。
\S 匹配任何非空白字符。等價于 [^ \f\n\r\t\v]。
\t 匹配一個制表符。等價于 \x09 和 \cI。
\v 匹配一個垂直制表符。等價于 \x0b 和 \cK。
\w 匹配包括下劃線的任何單詞字符。等價于’[A-Za-z0-9_]’。
\W 匹配任何非單詞字符。等價于 ’[^A-Za-z0-9_]’。
\xn 匹配 n,其中 n 為十六進(jìn)制轉(zhuǎn)義值。十六進(jìn)制轉(zhuǎn)義值必須為確定的兩個數(shù)字長。
\num 匹配 num,其中num是一個正整數(shù)。對所獲取的匹配的引用。
\n 標(biāo)識一個八進(jìn)制轉(zhuǎn)義值或一個后向引用。如果 \n 之前至少 n 個獲取的子表達(dá)式,則 n 為后向引用。否則,如果 n 為八進(jìn)制數(shù)字 (0-7),則 n 為一個八進(jìn)制轉(zhuǎn)義值。
\nm 標(biāo)識一個八進(jìn)制轉(zhuǎn)義值或一個后向引用。如果 \nm 之前至少有is preceded by at least nm 個獲取得子表達(dá)式,則 nm 為后向引用。如果 \nm 之前至少有 n 個獲取,則 n 為一個后跟文字 m 的后向引用。如果前面的條件都不滿足,若 n 和 m 均為八進(jìn)制數(shù)字 (0-7),則 \nm 將匹配八進(jìn)制轉(zhuǎn)義值 nm。
\nml 如果 n 為八進(jìn)制數(shù)字 (0-3),且 m 和 l 均為八進(jìn)制數(shù)字 (0-7),則匹配八