發新話題 Report thanks

小功能整理

小功能整理
控制視窗大小
複製內容到剪貼板
代碼:
<script>window.resizeTo(650,350)</script>
下拉選擇,變更網頁
複製內容到剪貼板
代碼:
<select onChange="location =this.options[this.selectedIndex].value;">
<option value="">--請選擇--</option>
<option value="http://tw.yahoo.com/"</option>
<option value="http://www.hinet.net/"</option>
</select>
雙擊捲動捲軸
複製內容到剪貼板
代碼:
<SCRIPT language=JavaScript>
var currentpos,timer;
function initialize()
{
timer=setInterval("scrollwindow()",1);
}
function sc(){
clearInterval(timer);
}
function scrollwindow()
{
currentpos=document.body.scrollTop+2;
[code]window.scroll(0,++currentpos);
if (currentpos !=document.body.scrollTop)
sc();
}
document.onmousedown=sc
document.ondblclick=initialize
</script>
透過按鈕變換網頁字型
複製內容到剪貼板
代碼:
<style>
<!--
.font1{font-family:Arial;font-size:14pt;}
-->
</style>
</head>
<body>
<table border="0"cellpadding="3"cellspacing="0"width="300"align="center">
<tr><td nowrap id="f1"class="font1"width="100%"align="center">
<a href="javascript:;"onclick="f1.style.fontFamily='細明體'">123,abC 細明體</a>&nbsp;&nbsp;&nbsp;
<a href="javascript:;"onclick="f1.style.fontFamily='標楷體'">123,abC 標楷體</a>
</td></tr>
</table>
表格內文字強制換行
複製內容到剪貼板
代碼:
<table width="580"border="0"cellpadding="2"cellspacing="0"style="WORD-BREAK:break-all;WORD-WRAP:break-word">

文字表單按enter 跳到下一表單,而不是直接送出submit

<input type="text"name="time"onkeydown="if(event.keyCode==13)event.keyCode=9">
<input type="text"name="name"onkeydown="if(event.keyCode==13)event.keyCode=9">
開全螢幕的視窗
複製內容到剪貼板
代碼:
window.open('Chromeless.htm','Chromeless','fullscreen=1');
禁止滑鼠右鍵功能.1(IE Only)
複製內容到剪貼板
代碼:
<HEAD>
<SCRIPT language=JavaScript>
if (navigator.appName.indexOf("Internet Explorer")!=-1)
document.onmousedown =noSourceExplorer;
function noSourceExplorer()
{if (event.button ==2|event.button ==3)
{alert("版權所有網頁研習室");
}
}
</SCRIPT>
</HEAD>
禁止滑鼠右鍵功能.2(IE &NC)
複製內容到剪貼板
代碼:
<SCRIPT language=Javascript>
function NoRightClick(evnt){
if (navigator.appName.toUpperCase().match(/NETSCAPE/)!=null)
{
if (evnt.which ==3)
{alert("版權所有網頁研習室");return false;
}
}else
if (event.button==2)alert("版權所有網頁研習室");
}
document.onmousedown =NoRightClick;
</SCRIPT>
---------
<!--begin
document.onmousedown=click;
document.onkeydown=click;
if (document.layers)window.captureEvents(Event.MOUSEDOWN);window.onmousedown=click;
if (document.layers)window.captureEvents(Event.KEYDOWN);window.onkeydown=click;
function click(e){
if (navigator.appName =='Netscape'){
if (e.which !=1){
alert("您想做甚麼呢?");
return false;}}
if (navigator.appName =="Microsoft Internet Explorer"){
if (event.button !=1){
alert("討厭!不要這樣嘛!");
return false;}}}
// end -->
=========
禁止滑鼠右鍵功能A2:code2.htm (IE Only)
<script language="JavaScript">
if (navigator.appName.indexOf("Internet Explorer")!=-1)
document.onmousedown =noSourceExplorer;
function noSourceExplorer()
{
if (event.button ==2|event.button ==3)
{
alert("禁止使用右鍵喔!!");
location.replace("alert.htm");
}
}
</script>
=========
禁止滑鼠右鍵功能B1:code3.htm (IE Only)
<HEAD>
<SCRIPT language=JavaScript>
<!--
function click(){
if (event.button==2){
alert('禁止使用右鍵')
}
}document.onmousedown=click
// -->
</SCRIPT>
</HEAD>
==============
禁止滑鼠左、右鍵功能B2:code4.htm (IE Only)
複製內容到剪貼板
代碼:
<BODY>
<script language="JavaScript">
<!--
function click()
{
if (event.button==2)
{
window.open("alert.htm","","width=500,height=300,toolbar=no,directories=no,menubar=no,top=140,left=140");
alert('千萬不要碰我');
}}document.onmousedown=click
// -->
</script>
</BODY>
註:if (event.button==1,2)左鍵也不可使用。
=========
禁止滑鼠右鍵功能C:code5.htm (IE Only)
複製內容到剪貼板
代碼:
<body onCONTEXTMENU="window.event.returnValue=false">
=========
讓滑鼠無法使用左鍵選取文字功能D:code6.htm(選取)
複製內容到剪貼板
代碼:
<BODY onSelectStart="event.returnValue=false">
=========
禁止滑鼠右鍵功能E:code7.htm
複製內容到剪貼板
代碼:
<body oncontextmenu="window.event.returnValue=false;window.external.AddFavorite ('http://www.webpage.idv.tv/','網頁研習室')">
按右鍵會跳出新增我的最愛
=========
禁止滑鼠右鍵功能F:
複製內容到剪貼板
代碼:
<BODY oncontextmenu="window.event.returnValue=false;alert('千萬不要碰我')">
按右鍵會跳出會跳出警告語
=========
禁止滑鼠右鍵、拖曳、選取功能G:(文字說明)
複製內容到剪貼板
代碼:
<body onDRAGSTART="window.event.returnValue=false"onCONTEXTMENU="window.event.returnValue=false"onSelectStart="event.returnValue=false">
1.onDRAGSTART="window.event.returnValue=false" //鎖住滑鼠拖曳功能
2.onCONTEXTMENU="window.event.returnValue=false"//鎖住右鍵選單及鍵盤鍵功能
3.onSelectStart="event.returnValue=false"    //鎖住滑鼠選取功能
--------

=========
更多禁止滑鼠右鍵功能:
複製內容到剪貼板
代碼:
<script language="javascript">
var message="討厭!不要偷看嘛!";
///////////////////////////////////
function clickIE(){if (document.all){alert(message);return false;}}
function clickNS(e){if
(document.layers||(document.getElementById&&!document.all)){
if (e.which==2||e.which==3){alert(message);return false;}}}
if (document.layers)
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
// -->
</script>
// 鍵盤健也無效哦
=========
複製內容到剪貼板
代碼:
<script language="javascript">
function JM_cc(ob){
var obj=MM_findObj(ob);if (obj){
obj.select();js=obj.createTextRange();js.execCommand("Copy");}
}

function MM_findObj(n,d){//v4.0
var p,i,x; if(!d)d=document;if((p=n.indexOf("?"))>0&&parent.frames.length){
d=parent.frames[n.substring(p+1)].document;n=n.substring(0,p);}
if(!(x=d[n])&&d.all)x=d.all[n];for (i=0;!x&&i<d.forms.length;i++)x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++)x=MM_findObj(n,d.layers[i].document);
if(!x &&document.getElementById)x=document.getElementById(n);return x;
}
</script>
=========
複製內容到剪貼板
代碼:
<script language="JavaScript">
<!--
function right(e)
{
if(navigator.appName =='Microsoft Internet Explorer'&&
(event.button ==2||event.button ==3))
{
alert("想偷原始碼...");
alert("給你點顏色瞧瞧!");
if(confirm("怕了嗎!"))
{
alert("看你求饒的份上,今天就放你一馬..");
return false;
}
else
{
alert("哎喲!挺不講理的!看我的厲害...");
i=3;
do
{
window.open("http://www.coobila.com");
}while(i=3);
}
}
}
document.onmousedown=right;if (document.layers)
window.captureEvents(Event.MOUSEDOWN);
window.onmousedown=right;
-->
</script>
讓退回鍵、切換鍵、鍵盤鍵失效,不得使用於表單上
複製內容到剪貼板
代碼:
<SCRIPT language=JavaScript>
<!--begin
document.onmousedown=click;
document.onkeydown=click;
if (document.layers)window.captureEvents(Event.MOUSEDOWN);window.onmousedown=click;
if (document.layers)window.captureEvents(Event.KEYDOWN);window.onkeydown=click;
function click(e){
if (navigator.appName =='Netscape'){
if (e.which !=1){
alert("請尊重智慧財產權");
return false;}}
if (navigator.appName =="Microsoft Internet Explorer"){
if (event.button !=1){
alert("請尊重智慧財產權");
return false;}}}
// end -->
</SCRIPT>[code]

禁止使用ctrl+N功能鍵

<body onkeydown='if(event.keyCode==78&&event.ctrlKey)return false;'>

禁止退回前一頁功能

[code]<BODY oncontextmenu="return false"onkeydown="if(event.keyCode==8||event.keyCode==37)return false;"onunload="if(event.clientY<0)document.location=document.location.href">
禁止複製圖檔功能:
複製內容到剪貼板
代碼:
<body oncontextmenu="return false"ondragstart="return false"onselectstart="return false"scroll="auto">
禁止存檔功能:
複製內容到剪貼板
代碼:
<noscript>
<iframe src=nosave.htm width=650height=90marginwidth=0marginheight=0hspace=0vspace=0frameborder=0scrolling=no>
</iframe>
</noscript>
隱藏狀態列顯示功能:
複製內容到剪貼板
代碼:
<script language="javascript">
<!--Begin
function hidestatus(){
window.status=''
return true
}
if (document.layers)
document.captureEvents(Event.MOUSEOVER |Event.MOUSEOUT)
document.onmouseover=hidestatus
document.onmouseout=hidestatus
// -->
</script>
全部隱藏狀態列顯示功能:
複製內容到剪貼板
代碼:
<base onmouseover="window.status='';return true">
如果您喜歡這篇文章,請按「讚」或分享給您的朋友,以示鼓勵。

TOP

thanks