博文

目前显示的是 十一月, 2013的博文

javascript & call

1, Test call function of Array var slice = Array.prototype.slice; alert("slice.call(NaN).length:"+slice.call(NaN).length);  //  result : 0 alert("slice.call({0:'foo',length:'10',9:'2'})[0]:"+slice.call({0:'foo',length:'10',9:'2'})[0]); // result : foo alert("slice.call({0:'foo',length:'10',9:'2'})[9]:"+slice.call({0:'foo',length:'10',9:'2'})[9]); // result : 2 alert("slice.call({0:'foo',length:'bar'})[0]:"+slice.call({0:'foo',length:'bar'})[0]); //result : undefined So, function call(arg) , "arg" is Set of name/value pairs, set enclosed by a pair of curly braces {} , "length" is length of array, others are order number of array. 2, Mouse position <script> function mouseMove(ev) {  ev= ev || window.event;   var mousePos = mouseCoords(ev);   //alert(ev.pageX);       document.get

Tells Internet Explorer to display a webpage in IE10 mode, if possible

1. This example tells Internet Explorer to display a webpage in IE10 mode, if possible. <meta http-equiv="X-UA-Compatible" content="IE=10"> This example tells Internet Explorer to display a webpage in last IE mode or chrome core frame, if possible. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> is better. 2.  <meta name="viewport" content="width=device-width">, this is for mobile.  HTML5 Boilerplate: html5boilerplate.com h t t p s: // github.com / h5bp/html5-boilerplate/blob/v4.0.0/doc/README.md

css & lu li

1. 2.- 3.- 4.- 5.- 6. 7. 8. 9.- 10.- 11.: <style type="text/css"> <!--  for jQuery .li_bg1 { background:#6495ed; } .li_bg2 { background:#b0c4de; } .li_color1{ color: #fff;background:#6495ed;} li:hover{     background:rgb(180,70,120) center no-repeat; } --> <!-- #menu ul{list-style:none;margin:0px;} #menu ul li{float:left} //Let all "li" to be at a line. li {list-style-type:square;}     // :none/disc/circle/square/ demical /lower- alpha /uper-alpha/lower- roman /upper-roman li {list-style-image:url(images/star.png);}// none/url(); li {list-style-position:outside;}//inside/outside li {li-style:disc url(img/a.gif) inside;} //list-style-type/list-style-image/list-style-position --> </style> <script type="text/javascript">           //$("#list1 li:even").addClass("li_bg1");           //$("#list1 li:odd").addClass("li_bg1");           $("#lis

Escape for XML & JSON

/**  * @author Jin  * @version 1.0.0  */ public class XmlTool {     public final static String JSONPARSE="forJSONparse";     public XmlTool() {         super();     }     /**      * Replace the five special characters by five "predefined entities".      * The XML specification defines five "predefined entities" representing special characters,      * and requires that tool honor them.The entities can be explicitly declared in a DTD.      * The table below lists the five XML predefined entities. The "Name" column mentions the entity's name. The "Character" column shows the character.      * <p>      * Name     Character      * quot     "      * amp     &      * apos     '      * lt     <      * gt     >      * </p>      * @param sChar      * @return String. The entities was explicitly declared in this string.      */    public static String replacePreEntities(String sChar){         String sR=""

String to JSON Object using backslash escapes (Encode and Decode)

http://json.org A string is a sequence of zero or more Unicode characters, wrapped in double quotes, using backslash escapes . A character is represented as a single character string. A string is very much like a C or Java string. In ECMA262 version 5 Javascript Object to JSON JSON to Javascript Object JSON.stringify() JSON.parse()  <script type="text/javascript">   var j='{"acct_id":100001,"acct_name":"na \\" me","email":"Jet \' mail"}';   var o=JSON.parse(j);   alert(o.acct_id+o.acct_name+o.email);   var jj='[{"acct_id":100000,"acct_name":"name0","email":"Jemail0"}]';    var oo=[];    oo=JSON.parse(jj);   alert(oo[0].acct_id+oo[0].acct_name+oo[0].email); //------         function getJsonObjLength(jsonObj){             var l=0;for(var i in jsonObj){l++;}return l;         }         var myObj={"A0E":{"1":

JQuery

Basic Syntax of JQuery: $(Selector).action() $: Indicates it is a jQuery. Selector: 3 types of name Id of an element (prefixed by # ). $(“#myButton”) - selects html element with id “ myButton ”. HTML element itself. $(“p”) - selects html paragraphs. CSS class (prefixed by . ( Period )) Etc. $(“.myclass”) - selects html elements which have their class ” myclass ”            //get the parent's the jQuery element.           var tblTmp =window.parent.$('#tt');           var data = window.parent.$.fn.panel.defaults.extractor(data);           var tmp = window.parent.$('<div></div>').html(data); Examples: $(":checkbox, :radio").click( showValues ) ; -for all <input type="checkbox" ...> and all < input type = "radio" ...> $("select").change( showValues ); - for all < select ...> function showValues() {   var fields = $( ":input" ).serializeArray();   $