收集 20 多個傳統 B/S 專案常見的 JavaScript 小技巧,雖部分屬於舊時代產物(如 IE 專屬、表單防複製),但仍具參考價值,適合維護舊系統或理解歷史演進。
<body oncontextmenu="return false"><bgsound> + <embed>window.open() / win.close()<noscript><iframe src="*.html"></iframe></noscript><object id=closes ...><param name="Command" value="Close"></object> <body onload="window.setTimeout('closes.Click()',10000)">onselectstart="return false"、oncopy="return false"、onpaste="return false"<link rel="Shortcut Icon" href="favicon.ico"><input style="ime-mode:Disabled">if (window == top) top.location.href = "frames.htm";if (top.location != self.location) top.location = self.location;onclick="window.location='view-source:'+ 'https://example.com/'"createTextRange() + moveStart + collapse + select()document.referrer (JS) / Request.ServerVariables("HTTP_REFERER") (ASP)classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11"<meta http-equiv="pragma" content="no-cache"> 等三組 metastr.match(/\\D/)==null/[^\\x00-\\xff]/g.test(s)onpropertychange="this.style.posHeight=this.scrollHeight"new Date(dd).valueOf() - dadd*24*60*60*1000onkeydown="if(event.keyCode==13)event.keyCode=9"createTextRange, attachEvent, expression) 已淘汰,請改用標準 DOM API。window.open 參數) 在現代瀏覽器多被攔截器限制,改用模態對話框或單頁應用路由。