幾個寫網頁的小技巧
2 月.11, 2005 in General
角括號會被當作 html Tag 辨識,所以只好用全形的字代替,想使用的人就請自行更換。
1. 禁止右鍵:
<body oncontextmenu=return(false)>
2.禁止選擇:
<body selectstart=”return false”>
3.禁止貼上:
<body onpaste=”return false”>
4.禁止直接訪問 (必須在框架內才有用):
<script>
if (top == self)top.location.href = “page.htm”;
</script>
5.禁止 Frame 引用:
<script>
if (top != self) top.location.href = “page.htm”;
</script>
6.禁止功能鍵 Shift, Alt, Ctrl:
<script> function key() { if(event.shiftKey) alert("Shift 不可使用!"); } document.onkeydown=key; </script>
7.讀取網址:
<SCRIPT>document.write(self.location)</SCRIPT>
8.讀取網址後的參數:
<SCRIPT>
var add = top.location;
add = add.toString();
document.write (add.substring(add.indexOf(“?”)+1,add.length));
</SCRIPT>
9.滑鼠游標在連結上自動點選:
<script> function mClk2() { var source=event.srcElement; if (source.tagName=="A") { source.click();self.focus(); } } document.write("<div onmouseover=mClk2();>"); </script>
Leave a Reply