<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <ptml xmlns=" http://www.w3.org/1999/xhtml "> <pead> <meta http-equiv=" Content-type "content=" text/html; charset=gb2312 "/> <title>javascript web page write </title> <style type=" Text/css "> * {-moz-user-selec T:none; border:0px; } #tips {width:850px; padding-top:8px; padding-bottom:8px; Background: #999999; Color: #FFFFFF; Text-align:center; Margin:auto; font-size:14px; } </style> <script type= "Text/javascript" > var Is_mouse_down = false var is_first=1 function Create (evt) { Evt=evt?evt:window.event if (is_mouse_down) {if (Evt.ctrlkey) {Clean (EVT)} else {write (evt)}}} function Write (evt) {evt=evt?evt:window.event var obj_ni An=document.createelement ("DIV") obj_nian.style.position= "Absolute" obj_nian.style.left=evt.clientx-10+ "px" obj_nian.style.top=evt.clienty-10+ "px" switch (Is_first) {Case 1:obj_nian.innerhtml= "Liu"; Case 2:obj_nian.innerhtml= "Nian"; Case 3:obj_nian.innerhtml= "I"; Case 4:obj_nian.innerhtml= "XI"; Case 5:obj_nian.innerhtml= "Huan"; Case 6:obj_nian.innerhtml= "You"; Default:obj_nian.innerhtml= "Error"; } is_first+=1 if (is_first==7) {is_first=1} color_nian= RGB (+math.floor () math.random) + " %, "+math.floor (Math.random () *100) +"%, +math.floor (Math.random () *100) + "%)" Obj_nian.style.color=color_nian document.body.appendChild (Obj_nian)} function Clean (evt) {Evt=evt?evt:window. Event Evt.srcobj=evt.srcelement?evt.srcelement:evt.target if (evt.srcobj.tagname== "DIV" && (evt.srcObj.in nerhtml== "Liu" | | evt.srcobj.innerhtml== "Nian" | | evt.srcobj.innerhtml== "I" | | Evt.srcObj.innerhtml== "XI" | | evt.srcobj.innerhtml== "Huan" | | evt.srcobj.innerhtml== "You") {evt.srcobj.innerhtml= "}} document.onmousedown=function () {IS_MOUSE_DOWN=TR UE} document.onmousemove=create document.onmouseup=function () {is_mouse_down=false} </script> </pead> & Lt;body onselectstart= "Javascript:return false" > <div id= "Tips" > Tips: Hold down the left mouse button, drag in the page to write; While holding down CTRL and the left mouse button, drag in the page to erase the word </div> </body> </ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]