网(LieHuo.Net)教程 最近有用户想实现AJAX写库,前台的文本框想替换成FCK编辑器,现在给出静态页调用FCK的一个参考例子,有兴趣的用户可以参考一下:
以下为引用的内容: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>FCKeditor - Sample - LIEHUO.NET</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="robots" content="noindex, nofollow" /> <link href="../sample.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="fckeditor/fckeditor.js"></script>//修改为自己的src <script type="text/javascript"> window.onload = function() { // Automatically calculates the editor base path based on the _samples directory. // This is usefull only for these samples. A real application should use something like this: // oFCKeditor.BasePath = '/fckeditor/' ; // '/fckeditor/' is the default value. var sBasePath = "./fckeditor/" ;//这里修改为你网站的fck编辑器文件夹的相对路径 var oFCKeditor = new FCKeditor( 'FCKeditor1' ) ; oFCKeditor.BasePath = sBasePath ; oFCKeditor.ReplaceTextarea() ; } function btnclick() { var oEditor = FCKeditorAPI.GetInstance('FCKeditor1') ; // Get the editor contents in XHTML. alert( oEditor.GetXHTML( true ) ) ; // "true" means you want it formatted.获取fck编辑器的值的方法 } </script> </head> <body> <div> <textarea name="FCKeditor1" rows="10" cols="80" style="width: 100%; height: 200px"><p>This is some <strong>sample text</strong>. You are using <a href="http://www.fckeditor.net/">FCKeditor</a>.</p></textarea> </div> <br /> <input id="btn" type="button" value="get content" onclick="btnclick()"/> </body> </html> |