More than 200 JS tricks code (eight) __js

Source: Internet
Author: User
Tags anonymous
199. mode window Parent window var url= "aaa.jsp"; var   data=showmodaldialog (Url,null, "dialogheight:400px;dialogheight:600px;center:yes;help:no;status:no;
Resizab   Le:yes;edge:sunken ");
if (data)  alert (Data.value);
   Sub Window var data=new object ();
"Data.value1=";
Window.returnvalue=data;
Window.close ();      200. Dynamically set events with parameters <input type= "text"  name= "A1" > <script language= JavaScript > <!--function hah (para) { alert (para)} a1.onclick=function () { hah (' canshu  ')
}//a1.attachevent ("onclick", function () {hah (' parameter ')});
--> </script>//     201. Convert URL to 16 form  var ret =  ';    for (var i=0; i < str.length; i++)  {  var ch =
 str.charat (i);
  var code = str.charcodeat (i);     if (code < 128 && ch !=  ' ['  && ch !=  '  && ch !=  ' = ')   {   ret 
+= ch; &NBSP;&NBSP}   else   {   ret +=  "["  + code.tostring (16)
 +  "]"; &NBSP;&NBSP} &nbsp}  return ret;//     202. Opens a new window and sets the newly opened window to the active window var newwin=
window.open ("xxxx");
Newwin.focus ()//     203. Error-Tolerant script JS does not do anything when it encounters script errors:window.onerror = donothing; The syntax for the specified error handle is: Window.onerror = handleerror function handleerror (message, uri, line) {//   Prompts the user that the page may not respond correctly return true; //  This will terminate the default information}//in the case of a page Error   window redirection in 204.JS: Window.navigate ("
http://www.sina.com.cn ")//  205. Prevent link text from wrapping document.body.nowrap=true;//  206. Determine if the character matches.
String.match (regexpression)//  207. Href= "Javascript:document. form.name.value= ' test '; void (0); Can not use onclick= "javacript:document."
FORM.NAME.V   alue= ' test ';return false; '  When using the inline method to add event handling feet, there is a process that is packaged as an anonymous function, that is to say, onclick= "javacript:document." Form.name.value= ' Test ';return false; ' was packaged as: Functoin anonymous () {    document.
Form.name.value= ' Test ';return false;
As a member function onclick. and href= "Javascript:document. form.name.value= ' test '; void (0);
is equivalent to executing a global statement, when using the return statement   reports an error using the return statement outside the function.     208. For page magnification <p onmouseover= "this.style.zoom= ' 200% '"  onmouseout= "this.style.zoom=" Normal ' "> Sdsdsdsdsdsdsdsds </p>//  209. Placed at the far right of the page <input type=" text " value= ' bu2 '    style= "Float:right" >//  210. Controls the display of different colors by using the style <style> tr{bgcolor:expression (this.bgcolor= (
This.rowindex)%2==0 )?  ' white '  :  ' yellow '); } </style> <table id= "otable"  width= " border=" 1 " style=" Border-collapse: Collapse; " > <tr><td> </td></tr> <tr><td> </td></tr> <tr> <td> </td></tr> <tr><td> </td></tr> <tr><td> </td></tr > </table>//  211. Full Screen maximization Newwindow=window.open ("", "", "scrollbars") if  (document.all) {  Newwindow.moveto (0,0)  newwindow.resizeto (screen.width,screen.height)}//  212. Resolves node values in XML by name var 
Xmldoc=new activexobject ("MSXML");
Xmldoc.url= "D:/abc.xml";
Aroot=xmldoc.root; A1.innertext=aroot.children.item ("name"). text;//     213. Parse XML values on the page  <a href= "http:// Msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/html/5996c682-3472-4b03-9fb0-1e08 ">http://
Msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/html/5996c682-3472-4b03-9fb0-1e08</a>   fcccdf35.asp//  214. See how many carriage returns are inside a string, the return value is an array var s=value.match (/\n/g), or if (s) if (s.length==9) {alert (' 10 lines '); return false;}
  215. Obtain ASC code var s= ' AA '; Alert (S.charcodeat (1))//   216. Text Right Align <input type= "text"  value= "123"  style= "Text-align:right" >//  217. Determine whether a method exists Function pagecallback ( Response) { alert (response);} if (Pagecallback)  alert (1)/     218. Determines whether a variable defines if (typeof (a) =
= "undefined") { alert ()}//     219.javascript executes the executable program on this machine, it needs to be set to trustworthy or reduce IE security level <script>
function exec  (command)  {    window.oldOnError = window.onerror;
    window._command = command;     window.onerror = function  (err)  {       if  (Err.indexof (' utomation ')  != -1)  {         alert (' command has been banned by the user.
');
        return true;
      }       else return false;
    };     var wsh = new activexobject (' Wscript.Shell ');     if  (WSH)       wsh.
Run (command);
    window.onerror = window.oldOnError; &NBSP;&NBSP} </script> Invocation Mode <a href= "javascript:  onclick=" exec (' D:/test.bat ') > Test </a
>//   220. Pop-up new page, close the old page, do not pop-up prompt box  var w=screen.availWidth-10;
   var h=screen.availHeight-10;    var swin=window.open ("/mc/mc/message_management.jsp",   "Bgsmbest", "Scrollbars=yes,
Status,location=0,menubar=0,toolbar=0,resizable=no,top=0,left=0,height= "+h+", W   idth= "+w";
   window.opener=null;    window.close ()//  221. Can enter the Drop-down box <span> <input name= "Department1"  id= " Department1 " style="  border-right:0;width:130 " autocomplete=" Off "> <span style=" width : 150;overflow:hidden "> <select  style=" width:150;margin-left:-130 "  onchange= "Department1.value=value" > <option value= "></option> <option value=" ASDFASFADF ">asdfasfadf</option> <option value=" 546546 ">546546</option></select>  //     222. Define global variables in the method function globalvar  (script)  {         eval (script);//all navigators   //window.execscript (script);  //for  ie only} globalvar (' window.haha =  ').
/system "; ');
alert (haha);//define global variables in the method, where haha is the global variable   223. Displays the value of all properties and properties of an object Var a=new object ();
A.name= ' A1 '; a.***= ' Mail ' for (var p in a) { alert (p+ "=" +a[p])}//     224.16 is converted into 10-in-system Var  n = parseint ("2AE", 16);//here will be 16 into the  2AE  into  10  number, get  n  value is   686     225. Copy and paste <BODY> <input type= "file"  name= ' A1 ' ><input type= "button"  value= ' copy and paste '  onclick= ' haha () "&Gt;<div id= "AA" ></div> <script language= "JavaScript" > <!--function haha () {
 clipboarddata.setdata ("Text", A1.value);
 aa.innertext=clipboarddata.getdata ("Text"); //--> </SCRIPT> </body>//  226. Get Object Type switch  (object.constructor) {   case  date:        case number:        case  string:        case myobject:         Default:    .}      227. Reload picture // 
  228. FONT_EFFECT.HTC <public:attach event= "onmouseover"  onevent= "Glowit ()"  /> <public: Attach event= "onmouseout"  onevent= "Noglow ()"  /> <script language= "JScript" >//
Defines a variable that holds the font color var color; Function glowit () { color=element.sTyle.backgroundcolor;  element.style.backgroundcolor= ' White '} function noglow () {  element.style.backgroundcolor= Color} </SCRIPT>  //abc.css tr{behavior:url (FONT_EFFECT.HTC);}   229. You can change the colors of the form through CSS and HTC, IE only support// xxx.html <link rel= "stylesheet"  type= "Text/css"  href= "abc.css" > <table border= ' 1 '   id= "A1" > <tr style= "background-color:red" >  <TD>1</TD>  <td >2</TD>  <TD>3</TD> </TR> <tr style= "Background-color:yellow" >  
<TD>4</TD>  <TD>5</TD>  <TD>6</TD> </TR> </table>//   230. Draw points on the page function a (x,y,color) { document.write (" ")}//   231. Automatically close Web page <script language=" jaVascript "> <!--settimeout (' Window.close (); ',  10000);  //60 seconds to close// --> </script> <p  align= "Center" > this page closes automatically after 10 seconds, please note refresh page </p>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.