Category Archives: javascript

常见的(Wysiwyg – 所见即所得)web编辑器

Wysiwyg – 所见即所得 是 What You See Is What You Get 的首字母缩略词。 CKEditor http://ckeditor.com/ FCKeditor http://www.fckeditor.net/ jWYSIWYG http://code.google.com/p/jwysiwyg/ markItUp http://markitup.jaysalvat.com/ NicEdit http://nicedit.com/ openWYSIWYG http://www.openwebware.com/ TinyMCE http://tinymce.moxiecode.com/ Whizzywig http://www.unverse.net/ WYMeditor http://www.wymeditor.org/ YUI editor http://developer.yahoo.com/yui/editor/

Posted in javascript | Leave a comment

javascript替换换行符的正确方法

js报错(Error: unterminated string literal),原因是字符串中包含换行符,需要用javascript替换换行符,兼容IE和Firefox的正确方法是,使用正则并且把\r和\n 分开替换: str.replace(/\r/ig, “”).replace(/\n/ig, “”); 需要注意的是: 1. javascript的replace只能替换一次,替换所有需要用到正则。 2. str.replace(/\r\n/ig, “”) 只适用于IE,Firefox和Opera并不起作用。 例子:

Posted in javascript | 3 Comments

obj2str

Posted in javascript | Leave a comment

演示使用闭包时出现的一个问题

这个问题是因为新的闭包函数被调用时,它引用的是数组的最后位置, 而不是你所期望的那个,所以getname和getage返回的都是user的age属性 正确写法如下:使用闭包创建动态方法的方法

Posted in javascript | Tagged | Leave a comment

随机颜色及反转颜色

Posted in javascript | Leave a comment