JS代碼判斷集錦大全第3/5頁(yè)
更新時(shí)間:2007年12月06日 21:15:02 投稿:mdxy-dxy
本文通過(guò)實(shí)例代碼給大家介紹了js代碼判斷的方法,代碼簡(jiǎn)單易懂,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友參考下吧
1. 禁止復(fù)制(copy),禁用鼠標(biāo)右鍵! <SCRIPT> //加入頁(yè)面保護(hù) function rf() {return false; } document.oncontextmenu = rf function keydown() {if(event.ctrlKey ==true || event.keyCode ==93 || event.shiftKey ==true){return false;} } document.onkeydown =keydown function drag() {return false;} document.ondragstart=drag function stopmouse(e) { if (navigator.appName == 'Netscape' && (e.which == 3 || e.which == 2)) return false; else if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2 || event.button == 3)) { alert("版權(quán)沒(méi)有,但別復(fù)制 :)"); return false; } return true; } document.onmousedown=stopmouse; if (document.layers) window.captureEvents(Event.MOUSEDOWN); window.onmousedown=stopmouse; </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[n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers.document); if(!x && document.getElementById) x=document.getElementById(n); return x; } </script> 2. JS和HTML互轉(zhuǎn) ~~~~~~~~~ <body> <style> body{font-size:9pt} textarea {color="#707888";font-family:"verdana"} .inputs {color="#707888";border:1px solid;background:#f4f4f4} </style> 在這里輸入你需要轉(zhuǎn)換的格式,可以是JavaScript也可以是DHtml. <br> <textarea id="codes" style="width:730;height:300"> </textarea> <br> <button class="inputs"> 清除輸出 </button> <button class="inputs"> 全選代碼 </button> <button class="inputs"> 拷貝代碼 </button> <button class="inputs"> 粘貼代碼 </button> <button class="inputs"> Js轉(zhuǎn)Html </button> <button class="inputs"> Html轉(zhuǎn)Js </button> <button class="inputs"> 點(diǎn)擊顯示源文件 </button> <button class="inputs"> 預(yù)覽代碼[F12] </button> <br> 這個(gè)是輸出格式的窗口: <br> <textarea id="outputs" style="width:730;height:300"></textarea> <br> 一個(gè)不好的消息:這個(gè)Js轉(zhuǎn)Html部分現(xiàn)在只是支持由這個(gè)程序生成的 <br> 作者:FlashSoft2000 QQ:14433548 <input id="hide" style='display:none'> <script> //定義title document.title="多功能網(wǎng)頁(yè)轉(zhuǎn)換" //顯示網(wǎng)頁(yè)源文件 function writes() { outputs.value=document.body.outerHTML; } //清除輸出窗口 function clears() { outputs.innerHTML=''; } //替換特定字符 //n1字符串,n2要替換的字,n3替換的字 function commute(n1,n2,n3) { var a1,a2,a3=0,a0='' a1=n1.length; a2=n2.length; for(x=0;x<=(a1-a2);x++) { if(n1.substr(x,a2)==n2) { a0+=n1.substring(a3,x); a0+=n3; x+=(a2-1); a3=x+1; } } if(a3<a1)a0+=n1.substring(a3,a1) { return a0; } } //轉(zhuǎn)換JavaScript為DHtml function js2html() { hide.value=codes.value hide.value=commute(hide.value,'\\"','"'); hide.value=commute(hide.value,'document.write("',''); hide.value=commute(hide.value,'")',''); hide.value=commute(hide.value,'<script>',''); hide.value=commute(hide.value,'<\/script>',''); outputs.value=hide.value } //轉(zhuǎn)換DHtml為JavaScript function html2js() { hide.value=codes.value hide.value=commute(hide.value,'"','\\"'); hide.value=commute(hide.value,'\\','\\\\'); hide.value=commute(hide.value,'<\/script>','<\\/script>'); outputs.value="<script>document.write(\""+hide.value+"\")<\/script>" } //預(yù)覽代碼 function seeHtm() { open().document.write("<title>測(cè)試代碼窗口</title>"+outputs.value); } //用快捷鍵F12預(yù)覽 document.onkeydown=seeHtms function seeHtms() { if((event.keyCode==123)) { open().document.write("<title>測(cè)試代碼窗口</title>"+outputs.value); } } //全選代碼 function ta() { outputs.select() } //拷貝代碼 function tc() { document.execCommand("Copy") } //粘貼代碼 function tp() { outputs.focus() document.execCommand("Paste") } </script>
相關(guān)文章
原生js實(shí)現(xiàn)fadein 和 fadeout淡入淡出效果
這篇文章主要介紹了通過(guò)原生js實(shí)現(xiàn)fadein 和 fadeout淡入淡出效果,需要的朋友可以參考下2014-06-06javascript設(shè)計(jì)模式--策略模式之輸入驗(yàn)證
策略模式中的策略就是一種算法或者業(yè)務(wù)規(guī)則,將這些策略作為函數(shù)進(jìn)行封裝,并向外提供統(tǒng)一的調(diào)用執(zhí)行,本文給大家介紹javascript設(shè)計(jì)模式--策略模式之輸入驗(yàn)證,需要的朋友參考下2015-11-11實(shí)例詳解BootStrap的動(dòng)態(tài)模態(tài)框及靜態(tài)模態(tài)框
要用bootStrap這個(gè)框架就必須要重載它的class類(lèi),也就是說(shuō)class要一樣。接下來(lái)通過(guò)實(shí)例代碼給大家介紹BootStrap的動(dòng)態(tài)模態(tài)框及靜態(tài)模態(tài)框,需要的朋友可以參考下2018-08-08JS實(shí)現(xiàn)仿新浪微博發(fā)布內(nèi)容為空時(shí)提示功能代碼
這篇文章主要介紹了JS實(shí)現(xiàn)仿新浪微博發(fā)布內(nèi)容為空時(shí)提示功能,2015-08-08JavaScript中利用Array和Object實(shí)現(xiàn)Map的方法
這篇文章主要介紹了JavaScript中利用Array和Object實(shí)現(xiàn)Map的方法,實(shí)例分析了javascript實(shí)現(xiàn)map的添加、獲取、移除、清空、遍歷等操作技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-07-07微信小程序自定義純凈模態(tài)框(彈出框)的實(shí)例代碼
這篇文章主要介紹了微信小程序自定義純凈模態(tài)框(彈出框)的實(shí)例代碼,代碼簡(jiǎn)答易懂,非常不錯(cuò),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-03-03