網(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> |