//各類尺寸 javascript
s += 「\r\n網頁可見區域寬:」+ document.body.clientWidth;
//過濾數字css
<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」> html
//特殊用途java
<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)」> web
//不緩存正則表達式
<META HTTP-EQUIV=「pragma」 CONTENT=「no-cache」>
<META HTTP-EQUIV=「Cache-Control」 CONTENT=「no-cache, must-revalidate」>
<META HTTP-EQUIV=「expires」 CONTENT=「0″> 緩存
//正則匹配 cookie
匹配中文字符的正則表達式: [\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,'’))」 app
//消除圖像工具欄dom
<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
{
window.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 下到上刷新
5 上到下刷新
6 左到右刷新
7 右到左刷新
8 豎百葉窗
9 橫百葉窗
10 錯位橫百葉窗
11 錯位豎百葉窗
12 點擴散
13 左右到中間刷新
14 中間到左右刷新
15 中間到上下
16 上下到中間
17 右下到左上
18 右上到左下
19 左上到右下
20 左下到右上
21 橫條
22 豎條 from: http://hi.baidu.com/atoat/item/f7d7c1c31154d847a9ba94ba