javascript技巧4

字號(hào):


    禁止選取
    <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">
    地址欄圖標(biāo)
    <link rel="Shortcut Icon" href="favicon.ico">
    favicon.ico 名字最好不變16*16的16色,放虛擬目錄根目錄下
    收藏欄圖標(biāo)
    <link rel="Bookmark" href="favicon.ico">
    查看源碼
    <input type=button value=查看網(wǎng)頁源代碼 onclick="window.location = 'view-source:'+ 'http://www.csdn.net/'">
    關(guān)閉輸入法
    <input>
    自動(dòng)全選
    <input type=text name=text1 value="123" onfocus="this.select()">
    ENTER鍵可以讓光標(biāo)移到下一個(gè)輸入框
    <input onkeydown="if(event.keyCode==13)event.keyCode=9">
    文本框的默認(rèn)值
    <input type=text value="123" onfocus="alert(this.defaultValue)">
    title換行
    obj.title = "123&#13sdfs&#32"
    獲得時(shí)間所代表的微秒
    var n1 = new Date("2004-10-10".replace(/-/g, "\/")).getTime()
    窗口是否關(guān)閉
    win.closed
    checkbox扁平
    <input type=checkbox><br>
    獲取選中內(nèi)容
    document.selection.createRange().duplicate().text
    自動(dòng)完成功能
    <input type=text autocomplete=on>打開該功能
    <input type=text autocomplete=off>關(guān)閉該功能
    窗口最大化
    <body onload="window.resizeTo(window.screen.width - 4,window.screen.height-50);window.moveTo(-4,-4)">
    無關(guān)閉按鈕IE
    window.open("aa.htm", "meizz", "fullscreen=7");
    統(tǒng)一編碼/解碼
    alert(decodeURIComponent(encodeURIComponent("http://你好.com?as= hehe")))
    encodeURIComponent對(duì)":"、"/"、";" 和 "?"也編碼
    表格行指示
    <tr onmouseover="this.bgColor='#f0f0f0'" onmouseout="this.bgColor='#ffffff'">