本人之前已经对javascript中unicode编码进行了解释,请参照http://ulhoo.com/blog/?p=72。但在不是十分理解unicode和html转义的情况下,可能会误用,所以下面会对它们再做比较容易理解的解释: 1.html中的转义:在html中如果遇到转义字符(如“ ”),不管你的页面字符编码是utf-8亦或者是GB2312,都会直接打印成相应的字符;而当遇到(如:“\u8981”【此处的8981是16进制值】)时,则不会打印成相应字符。 /* *html标记的转义 *@example *<p>Hello World!</p> * ||等价于 *<p>Hello World!</p> * ||等价于 *<p>Hello World!</p>*/ “ ” == “ ”; //false “ ”.length == 6; //true 2.html中的unicode编码:(如:” ”,【此处的160是10进制值】) 3.javascript内的unicode编码:当遇到unicode编码时(如:“\u8981”),则会打印成相应的字符;而在javasript标签中,不会对转义字符进行转义(如“  ”) /* *javascript中unicode编码 *@example *”\u8981″ == “要”; //true */ “\u8981″.length == 1; //true 4.javascript中的转义:(如:”\n”会转义成换行符) 5.javascript中unicode编码和字符的相互转化 /* *unicode编码和字符相互转化 */ “要”.charCodeAt() == 35201; //true,35201为10进制值 String.fromCharCode(35201) == “要”; //true,35201为10进制值 “\u89″ + “81″ == “要”; //false,值为”u8981″,是由于”\u”会转义成”u” //从unicode编码到字符的方法 [...]
Posts under ‘javascript’
host&domain
FROM:https://developer.mozilla.org/En/Same_origin_policy_for_JavaScript The same origin policy prevents a document or script loaded from one origin from getting or setting properties of a document from another origin. This policy dates all the way back to Netscape Navigator 2.0. 不同域禁止相互访问document对象 Mozilla considers two pages to have the same origin if the protocol, port (if one is specified), and [...]
浏览器对execCommand的支持情况
firefox支持的方法: decreaseFontSize heading hiliteColor increaseFontSize insertHTML paste (需要加netscape.security.PrivilegeManager.enablePrivilege( “UniversalXPConnect”)) ie7支持的方法: cut paste InsertButton InsertInputButton InsertFieldSet InsertIFrame InsertImage InsertInputCheckbox InsertInputFileUpload InsertInputHidden InsertInputImage InsertInputPassword InsertInputRadio InsertInputReset InsertInputSubmit InsertInputText InsertTextArea InsertSelectListbox InsertSelectDropdown InsertMarquee Unselect SaveAs 同时支持的方法: bold delete createLink fontName fontSize backColor foreColor formatBlock indent outdent insertHorizontalRule insertImage insertOrderedList insertUnorderedList insertParagraph(有差异) italic justifyRight justifyCenter justifyLeft undo redo unlink(有差异) [...]