editor.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874
  1. /*
  2. *☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆
  3. *★ ★
  4. *☆ eWebEditor - eWebSoft在线文本编辑器飞鱼修改版 ☆
  5. *★ ★
  6. *☆ 版权所有: eWebSoft.com ☆
  7. *★ ★
  8. *☆ 程序制作: eWeb开发团队 ☆
  9. *★ email:webmaster@webasp.net ★
  10. *☆ QQ:589808 ☆
  11. *★ ★
  12. *☆ 相关网址: [原版地址]http://www.eWebSoft.com/Product/eWebEditor/ ☆
  13. *★ [支持论坛]http://bbs.eWebSoft.com/ ★
  14. *☆ ☆
  15. *★ 主页地址: http://www.fiyu.net/ 飞鱼论坛 ★
  16. *☆ 有什么问题欢迎到飞鱼论坛提出! ☆
  17. *★ ★
  18. *★ ★
  19. *☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆
  20. */
  21. // 当前模式
  22. var sCurrMode = null;
  23. var bEditMode = null;
  24. // 连接对象
  25. var oLinkField = null;
  26. var sBaseUrl = document.location.protocol + '//' + document.location.host ;
  27. // 浏览器版本检测
  28. var BrowserInfo = new Object() ;
  29. BrowserInfo.MajorVer = navigator.appVersion.match(/MSIE (.)/)[1] ;
  30. BrowserInfo.MinorVer = navigator.appVersion.match(/MSIE .\.(.)/)[1] ;
  31. BrowserInfo.IsIE55OrMore = BrowserInfo.MajorVer >= 6 || ( BrowserInfo.MajorVer >= 5 && BrowserInfo.MinorVer >= 5 ) ;
  32. var yToolbars = new Array(); // 工具栏数组
  33. // 当文档完全调入时,进行初始化
  34. var bInitialized = false;
  35. document.onreadystatechange=function(){
  36. if (document.readyState!="complete") return;
  37. if (bInitialized) return;
  38. bInitialized = true;
  39. var i, s, curr;
  40. // 初始每个工具栏
  41. for (i=0; i<document.body.all.length;i++){
  42. curr=document.body.all[i];
  43. if (curr.className == "yToolbar"){
  44. InitTB(curr);
  45. yToolbars[yToolbars.length] = curr;
  46. }
  47. }
  48. oLinkField = parent.document.getElementsByName(sLinkFieldName)[0];
  49. if (ContentFlag.value=="0") {
  50. ContentEdit.value = oLinkField.value;
  51. ContentLoad.value = oLinkField.value;
  52. ContentFlag.value = "1";
  53. }
  54. setMode(config.InitMode);
  55. setLinkedField() ;
  56. eWebEditor.document.body.onpaste = onPaste ;
  57. eWebEditor.focus();
  58. }
  59. // 初始化一个工具栏上的按钮
  60. function InitBtn(btn) {
  61. btn.onmouseover = BtnMouseOver;
  62. btn.onmouseout = BtnMouseOut;
  63. btn.onmousedown = BtnMouseDown;
  64. btn.onmouseup = BtnMouseUp;
  65. btn.ondragstart = YCancelEvent;
  66. btn.onselectstart = YCancelEvent;
  67. btn.onselect = YCancelEvent;
  68. btn.YUSERONCLICK = btn.onclick;
  69. btn.onclick = YCancelEvent;
  70. btn.YINITIALIZED = true;
  71. return true;
  72. }
  73. //Initialize a toolbar.
  74. function InitTB(y) {
  75. // Set initial size of toolbar to that of the handle
  76. y.TBWidth = 0;
  77. // Populate the toolbar with its contents
  78. if (! PopulateTB(y)) return false;
  79. // Set the toolbar width and put in the handle
  80. y.style.posWidth = y.TBWidth;
  81. return true;
  82. }
  83. // Hander that simply cancels an event
  84. function YCancelEvent() {
  85. event.returnValue=false;
  86. event.cancelBubble=true;
  87. return false;
  88. }
  89. // Toolbar button onmouseover handler
  90. function BtnMouseOver() {
  91. if (event.srcElement.tagName != "IMG") return false;
  92. var image = event.srcElement;
  93. var element = image.parentElement;
  94. // Change button look based on current state of image.
  95. if (image.className == "Ico") element.className = "BtnMouseOverUp";
  96. else if (image.className == "IcoDown") element.className = "BtnMouseOverDown";
  97. event.cancelBubble = true;
  98. }
  99. // Toolbar button onmouseout handler
  100. function BtnMouseOut() {
  101. if (event.srcElement.tagName != "IMG") {
  102. event.cancelBubble = true;
  103. return false;
  104. }
  105. var image = event.srcElement;
  106. var element = image.parentElement;
  107. yRaisedElement = null;
  108. element.className = "Btn";
  109. image.className = "Ico";
  110. event.cancelBubble = true;
  111. }
  112. // Toolbar button onmousedown handler
  113. function BtnMouseDown() {
  114. if (event.srcElement.tagName != "IMG") {
  115. event.cancelBubble = true;
  116. event.returnValue=false;
  117. return false;
  118. }
  119. var image = event.srcElement;
  120. var element = image.parentElement;
  121. element.className = "BtnMouseOverDown";
  122. image.className = "IcoDown";
  123. event.cancelBubble = true;
  124. event.returnValue=false;
  125. return false;
  126. }
  127. // Toolbar button onmouseup handler
  128. function BtnMouseUp() {
  129. if (event.srcElement.tagName != "IMG") {
  130. event.cancelBubble = true;
  131. return false;
  132. }
  133. var image = event.srcElement;
  134. var element = image.parentElement;
  135. //if (element.YUSERONCLICK) eval(element.YUSERONCLICK + "anonymous()");
  136. if (navigator.appVersion.match(/MSIE (8)\./i)!=null){
  137. if (element.YUSERONCLICK) eval(element.YUSERONCLICK + "onclick(event)");
  138. }else{
  139. if (element.YUSERONCLICK) eval(element.YUSERONCLICK + "anonymous()");
  140. }
  141. element.className = "BtnMouseOverUp";
  142. image.className = "Ico";
  143. event.cancelBubble = true;
  144. return false;
  145. }
  146. // Populate a toolbar with the elements within it
  147. function PopulateTB(y) {
  148. var i, elements, element;
  149. // Iterate through all the top-level elements in the toolbar
  150. elements = y.children;
  151. for (i=0; i<elements.length; i++) {
  152. element = elements[i];
  153. if (element.tagName == "SCRIPT" || element.tagName == "!") continue;
  154. switch (element.className) {
  155. case "Btn":
  156. if (element.YINITIALIZED == null) {
  157. if (! InitBtn(element)) {
  158. alert("Problem initializing:" + element.id);
  159. return false;
  160. }
  161. }
  162. element.style.posLeft = y.TBWidth;
  163. y.TBWidth += element.offsetWidth + 1;
  164. break;
  165. case "TBGen":
  166. element.style.posLeft = y.TBWidth;
  167. y.TBWidth += element.offsetWidth + 1;
  168. break;
  169. case "TBSep":
  170. element.style.posLeft = y.TBWidth + 2;
  171. y.TBWidth += 5;
  172. break;
  173. case "TBHandle":
  174. element.style.posLeft = 2;
  175. y.TBWidth += element.offsetWidth + 7;
  176. break;
  177. default:
  178. alert("Invalid class: " + element.className + " on Element: " + element.id + " <" + element.tagName + ">");
  179. return false;
  180. }
  181. }
  182. y.TBWidth += 1;
  183. return true;
  184. }
  185. // 设置所属表单的提交或reset事件
  186. function setLinkedField() {
  187. if (! oLinkField) return ;
  188. var oForm = oLinkField.form ;
  189. if (!oForm) return ;
  190. // 附加submit事件
  191. oForm.attachEvent("onsubmit", AttachSubmit) ;
  192. if (! oForm.submitEditor) oForm.submitEditor = new Array() ;
  193. oForm.submitEditor[oForm.submitEditor.length] = AttachSubmit ;
  194. if (! oForm.originalSubmit) {
  195. oForm.originalSubmit = oForm.submit ;
  196. oForm.submit = function() {
  197. if (this.submitEditor) {
  198. for (var i = 0 ; i < this.submitEditor.length ; i++) {
  199. this.submitEditor[i]() ;
  200. }
  201. }
  202. this.originalSubmit() ;
  203. }
  204. }
  205. // 附加reset事件
  206. oForm.attachEvent("onreset", AttachReset) ;
  207. if (! oForm.resetEditor) oForm.resetEditor = new Array() ;
  208. oForm.resetEditor[oForm.resetEditor.length] = AttachReset ;
  209. if (! oForm.originalReset) {
  210. oForm.originalReset = oForm.reset ;
  211. oForm.reset = function() {
  212. if (this.resetEditor) {
  213. for (var i = 0 ; i < this.resetEditor.length ; i++) {
  214. this.resetEditor[i]() ;
  215. }
  216. }
  217. this.originalReset() ;
  218. }
  219. }
  220. }
  221. // 附加submit提交事件,大表单数据提交,远程文件获取,保存eWebEditor中的内容
  222. var bDoneAutoRemote = false;
  223. function AttachSubmit() {
  224. var oForm = oLinkField.form ;
  225. if (!oForm) return;
  226. if ((config.AutoRemote=="1")&&(!bDoneAutoRemote)){
  227. parent.event.returnValue = false;
  228. bDoneAutoRemote = true;
  229. remoteUpload();
  230. } else {
  231. var html = getHTML();
  232. ContentEdit.value = html;
  233. if (sCurrMode=="TEXT"){
  234. html = HTMLEncode(html);
  235. }
  236. splitTextField(oLinkField, html);
  237. }
  238. }
  239. // 提交表单
  240. function doSubmit(){
  241. var oForm = oLinkField.form ;
  242. if (!oForm) return ;
  243. oForm.submit();
  244. }
  245. // 附加Reset事件
  246. function AttachReset() {
  247. if (!bEditMode) setMode('EDIT');
  248. if(bEditMode){
  249. eWebEditor.document.body.innerHTML = ContentLoad.value;
  250. }else{
  251. eWebEditor.document.body.innerText = ContentLoad.value;
  252. }
  253. }
  254. // 粘贴时自动检测是否来源于Word格式
  255. function onPaste() {
  256. if (config.AutoDetectPasteFromWord && BrowserInfo.IsIE55OrMore) {
  257. var sHTML = GetClipboardHTML() ;
  258. var re = /<\w[^>]* class="?MsoNormal"?/gi ;
  259. if ( re.test( sHTML ) )
  260. {
  261. if ( confirm( "你要粘贴的内容好象是从Word中拷出来的,是否要先清除Word格式再粘贴?" ) )
  262. {
  263. cleanAndPaste( sHTML ) ;
  264. return false ;
  265. }
  266. }
  267. }
  268. else
  269. return true ;
  270. }
  271. function GetClipboardHTML() {
  272. var oDiv = document.getElementById("eWebEditor_Temp_HTML")
  273. oDiv.innerHTML = "" ;
  274. var oTextRange = document.body.createTextRange() ;
  275. oTextRange.moveToElementText(oDiv) ;
  276. oTextRange.execCommand("Paste") ;
  277. var sData = oDiv.innerHTML ;
  278. oDiv.innerHTML = "" ;
  279. return sData ;
  280. }
  281. function cleanAndPaste( html ) {
  282. // Remove all SPAN tags
  283. html = html.replace(/<\/?SPAN[^>]*>/gi, "" );
  284. // Remove Class attributes
  285. html = html.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/gi, "<$1$3") ;
  286. // Remove Style attributes
  287. html = html.replace(/<(\w[^>]*) style="([^"]*)"([^>]*)/gi, "<$1$3") ;
  288. // Remove Lang attributes
  289. html = html.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi, "<$1$3") ;
  290. // Remove XML elements and declarations
  291. html = html.replace(/<\\?\?xml[^>]*>/gi, "") ;
  292. // Remove Tags with XML namespace declarations: <o:p></o:p>
  293. html = html.replace(/<\/?\w+:[^>]*>/gi, "") ;
  294. // Replace the &nbsp;
  295. html = html.replace(/&nbsp;/, " " );
  296. // Transform <P> to <DIV>
  297. var re = new RegExp("(<P)([^>]*>.*?)(<\/P>)","gi") ; // Different because of a IE 5.0 error
  298. html = html.replace( re, "<div$2</div>" ) ;
  299. insertHTML( html ) ;
  300. }
  301. // 在当前文档位置插入.
  302. function insertHTML(html) {
  303. if (!validateMode()) return;
  304. if (eWebEditor.document.selection.type.toLowerCase() != "none")
  305. eWebEditor.document.selection.clear() ;
  306. eWebEditor.document.selection.createRange().pasteHTML(html) ;
  307. }
  308. // 设置编辑器的内容
  309. /*function setHTML(html) {
  310. ContentEdit.value = html;
  311. switch (sCurrMode){
  312. case "CODE":
  313. eWebEditor.document.designMode="On";
  314. eWebEditor.document.open();
  315. eWebEditor.document.write(config.StyleEditorHeader);
  316. eWebEditor.document.body.innerText=html;
  317. eWebEditor.document.body.contentEditable="true";
  318. eWebEditor.document.close();
  319. bEditMode=false;
  320. break;
  321. case "EDIT":
  322. eWebEditor.document.designMode="On";
  323. eWebEditor.document.open();
  324. eWebEditor.document.write(config.StyleEditorHeader+html);
  325. eWebEditor.document.body.contentEditable="true";
  326. eWebEditor.document.execCommand("2D-Position",true,true);
  327. eWebEditor.document.execCommand("MultipleSelection", true, true);
  328. eWebEditor.document.execCommand("LiveResize", true, true);
  329. eWebEditor.document.close();
  330. doZoom(nCurrZoomSize);
  331. bEditMode=true;
  332. eWebEditor.document.onselectionchange = function () { doToolbar();}
  333. break;
  334. case "TEXT":
  335. eWebEditor.document.designMode="On";
  336. eWebEditor.document.open();
  337. eWebEditor.document.write(config.StyleEditorHeader);
  338. eWebEditor.document.body.innerText=html;
  339. eWebEditor.document.body.contentEditable="true";
  340. eWebEditor.document.close();
  341. bEditMode=false;
  342. break;
  343. case "VIEW":
  344. eWebEditor.document.designMode="off";
  345. eWebEditor.document.open();
  346. eWebEditor.document.write(config.StyleEditorHeader+html);
  347. eWebEditor.document.body.contentEditable="false";
  348. eWebEditor.document.close();
  349. bEditMode=false;
  350. break;
  351. }
  352. eWebEditor.document.body.onpaste = onPaste ;
  353. eWebEditor.document.body.onhelp = onHelp ;
  354. eWebEditor.document.onkeydown = new Function("return onKeyDown(eWebEditor.event);");
  355. eWebEditor.document.oncontextmenu=new Function("return showContextMenu(eWebEditor.event);");
  356. if ((borderShown != "0")&&bEditMode) {
  357. borderShown = "0";
  358. showBorders();
  359. }
  360. initHistory();
  361. }*/
  362. // 设置编辑器的内容
  363. function setHTML(html) {
  364. if (!validateMode()) return;
  365. ContentEdit.value = html;
  366. if(bEditMode){
  367. eWebEditor.document.body.innerHTML = html;
  368. }else{
  369. eWebEditor.document.body.innerText = html;
  370. }
  371. }
  372. // 取编辑器的内容
  373. function getHTML() {
  374. var html;
  375. if(bEditMode){
  376. html = eWebEditor.document.body.innerHTML;
  377. }else{
  378. html = eWebEditor.document.body.innerText;
  379. }
  380. var re = new RegExp(sBaseUrl.replace(/\//,"\/"),"gi");
  381. html = html.replace(re, "");
  382. if (html=="") { html = " ";}
  383. return html;
  384. }
  385. // 在尾部追加内容
  386. function appendHTML(html) {
  387. if (!validateMode()) return;
  388. if(bEditMode){
  389. eWebEditor.document.body.innerHTML += html;
  390. }else{
  391. eWebEditor.document.body.innerText += html;
  392. }
  393. }
  394. // 从Word中粘贴,去除格式
  395. function PasteWord(){
  396. if (!validateMode()) return;
  397. eWebEditor.focus();
  398. if (BrowserInfo.IsIE55OrMore)
  399. cleanAndPaste( GetClipboardHTML() ) ;
  400. else if ( confirm( "此功能要求IE5.5版本以上,你当前的浏览器不支持,是否按常规粘贴进行?" ) )
  401. format("paste") ;
  402. eWebEditor.focus();
  403. }
  404. // 粘贴纯文本
  405. function PasteText(){
  406. if (!validateMode()) return;
  407. eWebEditor.focus();
  408. var sText = HTMLEncode( clipboardData.getData("Text") ) ;
  409. insertHTML(sText);
  410. eWebEditor.focus();
  411. }
  412. // 检测当前是否允许编辑
  413. function validateMode() {
  414. if (bEditMode) return true;
  415. alert("需转换为编辑状态后才能使用编辑功能!");
  416. eWebEditor.focus();
  417. return false;
  418. }
  419. // 格式化编辑器中的内容
  420. function format(what,opt) {
  421. if (!validateMode()) return;
  422. eWebEditor.focus();
  423. if (opt=="RemoveFormat") {
  424. what=opt;
  425. opt=null;
  426. }
  427. if (opt==null) eWebEditor.document.execCommand(what);
  428. else eWebEditor.document.execCommand(what,"",opt);
  429. eWebEditor.focus();
  430. }
  431. // 确保焦点在 eWebEditor 内
  432. function VerifyFocus() {
  433. if ( eWebEditor )
  434. eWebEditor.focus();
  435. }
  436. // 改变模式:代码、编辑、预览
  437. function setMode(NewMode){
  438. if (NewMode!=sCurrMode){
  439. var sBody = "";
  440. switch(sCurrMode){
  441. case "CODE":
  442. sBody = eWebEditor.document.body.innerText;
  443. break;
  444. case "EDIT":
  445. case "VIEW":
  446. sBody = eWebEditor.document.body.innerHTML;
  447. break;
  448. default:
  449. sBody = ContentEdit.value;
  450. break;
  451. }
  452. // 换图片
  453. try{
  454. document.all["eWebEditor_CODE"].className = "StatusBarBtnOff";
  455. document.all["eWebEditor_EDIT"].className = "StatusBarBtnOff";
  456. document.all["eWebEditor_VIEW"].className = "StatusBarBtnOff";
  457. document.all["eWebEditor_"+NewMode].className = "StatusBarBtnOn";
  458. }
  459. catch(e){
  460. }
  461. // 换内容
  462. switch (NewMode){
  463. case "CODE":
  464. eWebEditor.document.designMode="On";
  465. eWebEditor.document.open();
  466. eWebEditor.document.write(config.StyleEditorHeader);
  467. eWebEditor.document.body.innerText=sBody;
  468. eWebEditor.document.body.contentEditable="true";
  469. eWebEditor.document.oncontextmenu=new Function("return showContextMenu(eWebEditor.event);");
  470. eWebEditor.document.close();
  471. bEditMode=false;
  472. break;
  473. case "EDIT":
  474. eWebEditor.document.designMode="On";
  475. eWebEditor.document.open();
  476. eWebEditor.document.write(config.StyleEditorHeader);
  477. eWebEditor.document.body.innerHTML=sBody;
  478. eWebEditor.document.body.contentEditable="true";
  479. eWebEditor.document.oncontextmenu=new Function("return showContextMenu(eWebEditor.event);");
  480. eWebEditor.document.execCommand("2D-Position",true,true);
  481. eWebEditor.document.execCommand("MultipleSelection", true, true);
  482. eWebEditor.document.execCommand("LiveResize", true, true);
  483. eWebEditor.document.close();
  484. doZoom(nCurrZoomSize);
  485. bEditMode=true;
  486. break;
  487. case "VIEW":
  488. eWebEditor.document.designMode="off";
  489. eWebEditor.document.open();
  490. eWebEditor.document.write(config.StyleEditorHeader+sBody);
  491. eWebEditor.document.body.contentEditable="false";
  492. eWebEditor.document.close();
  493. bEditMode=false;
  494. break;
  495. }
  496. sCurrMode=NewMode;
  497. disableChildren(eWebEditor_Toolbar);
  498. if ((borderShown != "no")&&bEditMode) {
  499. borderShown = "no";
  500. showBorders()
  501. }
  502. }
  503. eWebEditor.focus();
  504. }
  505. // 使工具栏无效
  506. function disableChildren(obj){
  507. if (obj){
  508. obj.disabled=(!bEditMode);
  509. for (var i=0; i<obj.children.length; i++){
  510. disableChildren(obj.children[i]);
  511. }
  512. }
  513. }
  514. // 显示无模式对话框
  515. function ShowDialog(url, width, height, optValidate) {
  516. if (optValidate) {
  517. if (!validateMode()) return;
  518. }
  519. eWebEditor.focus();
  520. var arr = showModalDialog(url, window, "dialogWidth:" + width + "px;dialogHeight:" + height + "px;help:no;scroll:no;status:no");
  521. eWebEditor.focus();
  522. }
  523. // 全屏编辑
  524. function Maximize() {
  525. if (!validateMode()) return;
  526. window.open("dialog/fullscreen.htm?style="+config.StyleName, 'FullScreen'+sLinkFieldName, 'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,fullscreen=yes');
  527. }
  528. // 替换特殊字符
  529. function HTMLEncode(text){
  530. text = text.replace(/&/g, "&amp;") ;
  531. text = text.replace(/"/g, "&quot;") ;
  532. text = text.replace(/</g, "&lt;") ;
  533. text = text.replace(/>/g, "&gt;") ;
  534. text = text.replace(/'/g, "&#146;") ;
  535. text = text.replace(/\ /g,"&nbsp;");
  536. text = text.replace(/\n/g,"<br>");
  537. text = text.replace(/\t/g,"&nbsp;&nbsp;&nbsp;&nbsp;");
  538. return text;
  539. }
  540. // 插入特殊对象
  541. function insert(what) {
  542. if (!validateMode()) return;
  543. eWebEditor.focus();
  544. var sel = eWebEditor.document.selection.createRange();
  545. switch(what){
  546. case "excel": // 插入EXCEL表格
  547. insertHTML("<object classid='clsid:0002E510-0000-0000-C000-000000000046' id='Spreadsheet1' codebase='file:\\Bob\software\office2000\msowc.cab' width='100%' height='250'><param name='HTMLURL' value><param name='HTMLData' value='&lt;html xmlns:x=&quot;urn:schemas-microsoft-com:office:excel&quot;xmlns=&quot;http://www.w3.org/TR/REC-html40&quot;&gt;&lt;head&gt;&lt;style type=&quot;text/css&quot;&gt;&lt;!--tr{mso-height-source:auto;}td{black-space:nowrap;}.wc4590F88{black-space:nowrap;font-family:宋体;mso-number-format:General;font-size:auto;font-weight:auto;font-style:auto;text-decoration:auto;mso-background-source:auto;mso-pattern:auto;mso-color-source:auto;text-align:general;vertical-align:bottom;border-top:none;border-left:none;border-right:none;border-bottom:none;mso-protection:locked;}--&gt;&lt;/style&gt;&lt;/head&gt;&lt;body&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;&lt;x:ExcelWorkbook&gt;&lt;x:ExcelWorksheets&gt;&lt;x:ExcelWorksheet&gt;&lt;x:OWCVersion&gt;9.0.0.2710&lt;/x:OWCVersion&gt;&lt;x:Label Style='border-top:solid .5pt silver;border-left:solid .5pt silver;border-right:solid .5pt silver;border-bottom:solid .5pt silver'&gt;&lt;x:Caption&gt;Microsoft Office Spreadsheet&lt;/x:Caption&gt; &lt;/x:Label&gt;&lt;x:Name&gt;Sheet1&lt;/x:Name&gt;&lt;x:WorksheetOptions&gt;&lt;x:Selected/&gt;&lt;x:Height&gt;7620&lt;/x:Height&gt;&lt;x:Width&gt;15240&lt;/x:Width&gt;&lt;x:TopRowVisible&gt;0&lt;/x:TopRowVisible&gt;&lt;x:LeftColumnVisible&gt;0&lt;/x:LeftColumnVisible&gt; &lt;x:ProtectContents&gt;False&lt;/x:ProtectContents&gt; &lt;x:DefaultRowHeight&gt;210&lt;/x:DefaultRowHeight&gt; &lt;x:StandardWidth&gt;2389&lt;/x:StandardWidth&gt; &lt;/x:WorksheetOptions&gt; &lt;/x:ExcelWorksheet&gt;&lt;/x:ExcelWorksheets&gt; &lt;x:MaxHeight&gt;80%&lt;/x:MaxHeight&gt;&lt;x:MaxWidth&gt;80%&lt;/x:MaxWidth&gt;&lt;/x:ExcelWorkbook&gt;&lt;/xml&gt;&lt;![endif]--&gt;&lt;table class=wc4590F88 x:str&gt;&lt;col width=&quot;56&quot;&gt;&lt;tr height=&quot;14&quot;&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/body&gt;&lt;/html&gt;'> <param name='DataType' value='HTMLDATA'> <param name='AutoFit' value='0'><param name='DisplayColHeaders' value='-1'><param name='DisplayGridlines' value='-1'><param name='DisplayHorizontalScrollBar' value='-1'><param name='DisplayRowHeaders' value='-1'><param name='DisplayTitleBar' value='-1'><param name='DisplayToolbar' value='-1'><param name='DisplayVerticalScrollBar' value='-1'> <param name='EnableAutoCalculate' value='-1'> <param name='EnableEvents' value='-1'><param name='MoveAfterReturn' value='-1'><param name='MoveAfterReturnDirection' value='0'><param name='RightToLeft' value='0'><param name='ViewableRange' value='1:65536'></object>");
  548. break;
  549. case "nowdate": // 插入当前系统日期
  550. var d = new Date();
  551. insertHTML(d.toLocaleDateString());
  552. break;
  553. case "nowtime": // 插入当前系统时间
  554. var d = new Date();
  555. insertHTML(d.toLocaleTimeString());
  556. break;
  557. case "br": // 插入换行符
  558. insertHTML("<br>")
  559. break;
  560. case "code": // 代码片段样式
  561. insertHTML('<table width=95% border="0" align="Center" cellpadding="6" cellspacing="0" style="border: 1px Dotted #CCCCCC; TABLE-LAYOUT: fixed"><tr><td bgcolor=#FDFDDF style="WORD-WRAP: break-word"><font style="color: #990000;font-weight:bold">以下是代码片段:</font><br>'+HTMLEncode(sel.text)+'</td></tr></table>');
  562. break;
  563. case "quote": // 引用片段样式
  564. insertHTML('<table width=95% border="0" align="Center" cellpadding="6" cellspacing="0" style="border: 1px Dotted #CCCCCC; TABLE-LAYOUT: fixed"><tr><td bgcolor=#F3F3F3 style="WORD-WRAP: break-word"><font style="color: #990000;font-weight:bold">以下是引用片段:</font><br>'+HTMLEncode(sel.text)+'</td></tr></table>');
  565. break;
  566. case "big": // 字体变大
  567. insertHTML("<big>" + sel.text + "</big>");
  568. break;
  569. case "small": // 字体变小
  570. insertHTML("<small>" + sel.text + "</small>");
  571. break;
  572. default:
  573. alert("错误参数调用!");
  574. break;
  575. }
  576. sel=null;
  577. }
  578. // 显示或隐藏指导方针
  579. var borderShown = "no";
  580. function showBorders() {
  581. if (!validateMode()) return;
  582. var allForms = eWebEditor.document.body.getElementsByTagName("FORM");
  583. var allInputs = eWebEditor.document.body.getElementsByTagName("INPUT");
  584. var allTables = eWebEditor.document.body.getElementsByTagName("TABLE");
  585. var allLinks = eWebEditor.document.body.getElementsByTagName("A");
  586. // 表单
  587. for (a=0; a < allForms.length; a++) {
  588. if (borderShown == "no") {
  589. allForms[a].runtimeStyle.border = "1px dotted #FF0000"
  590. } else {
  591. allForms[a].runtimeStyle.cssText = ""
  592. }
  593. }
  594. // Input Hidden类
  595. for (b=0; b < allInputs.length; b++) {
  596. if (borderShown == "no") {
  597. if (allInputs[b].type.toUpperCase() == "HIDDEN") {
  598. allInputs[b].runtimeStyle.border = "1px dashed #000000"
  599. allInputs[b].runtimeStyle.width = "15px"
  600. allInputs[b].runtimeStyle.height = "15px"
  601. allInputs[b].runtimeStyle.backgroundColor = "#FDADAD"
  602. allInputs[b].runtimeStyle.color = "#FDADAD"
  603. }
  604. } else {
  605. if (allInputs[b].type.toUpperCase() == "HIDDEN")
  606. allInputs[b].runtimeStyle.cssText = ""
  607. }
  608. }
  609. // 表格
  610. for (i=0; i < allTables.length; i++) {
  611. if (borderShown == "no") {
  612. allTables[i].runtimeStyle.border = "1px dotted #BFBFBF"
  613. } else {
  614. allTables[i].runtimeStyle.cssText = ""
  615. }
  616. allRows = allTables[i].rows
  617. for (y=0; y < allRows.length; y++) {
  618. allCellsInRow = allRows[y].cells
  619. for (x=0; x < allCellsInRow.length; x++) {
  620. if (borderShown == "no") {
  621. allCellsInRow[x].runtimeStyle.border = "1px dotted #BFBFBF"
  622. } else {
  623. allCellsInRow[x].runtimeStyle.cssText = ""
  624. }
  625. }
  626. }
  627. }
  628. // 链接 A
  629. for (a=0; a < allLinks.length; a++) {
  630. if (borderShown == "no") {
  631. if (allLinks[a].href.toUpperCase() == "") {
  632. allLinks[a].runtimeStyle.border = "1px dashed #000000"
  633. allLinks[a].runtimeStyle.width = "20px"
  634. allLinks[a].runtimeStyle.height = "16px"
  635. allLinks[a].runtimeStyle.backgroundColor = "#FFFFCC"
  636. allLinks[a].runtimeStyle.color = "#FFFFCC"
  637. }
  638. } else {
  639. allLinks[a].runtimeStyle.cssText = ""
  640. }
  641. }
  642. if (borderShown == "no") {
  643. borderShown = "yes"
  644. } else {
  645. borderShown = "no"
  646. }
  647. scrollUp()
  648. }
  649. // 返回页面最上部
  650. function scrollUp() {
  651. eWebEditor.scrollBy(0,0);
  652. }
  653. // 缩放操作
  654. var nCurrZoomSize = 100;
  655. var aZoomSize = new Array(10, 25, 50, 75, 100, 150, 200, 500);
  656. function doZoom(size) {
  657. eWebEditor.document.body.runtimeStyle.zoom = size + "%";
  658. nCurrZoomSize = size;
  659. }
  660. // 拼写检查
  661. function spellCheck(){
  662. ShowDialog('dialog/spellcheck.htm', 300, 220, true)
  663. }
  664. // 查找替换
  665. function findReplace(){
  666. ShowDialog('dialog/findreplace.htm', 320, 165, true)
  667. }
  668. // 相对(absolute)或绝对位置(static)
  669. function absolutePosition(){
  670. var objReference = null;
  671. var RangeType = eWebEditor.document.selection.type;
  672. if (RangeType != "Control") return;
  673. var selectedRange = eWebEditor.document.selection.createRange();
  674. for (var i=0; i<selectedRange.length; i++){
  675. objReference = selectedRange.item(i);
  676. if (objReference.style.position != 'absolute') {
  677. objReference.style.position='absolute';
  678. }else{
  679. objReference.style.position='static';
  680. }
  681. }
  682. eWebEditor.content = false;
  683. eWebEditor.setActive();
  684. }
  685. // 上移(forward)或下移(backward)一层
  686. function zIndex(action){
  687. var objReference = null;
  688. var RangeType = eWebEditor.document.selection.type;
  689. if (RangeType != "Control") return;
  690. var selectedRange = eWebEditor.document.selection.createRange();
  691. for (var i=0; i<selectedRange.length; i++){
  692. objReference = selectedRange.item(i);
  693. if (action=='forward'){
  694. objReference.style.zIndex +=1;
  695. }else{
  696. objReference.style.zIndex -=1;
  697. }
  698. objReference.style.position='absolute';
  699. }
  700. eWebEditor.content = false;
  701. eWebEditor.setActive();
  702. }
  703. // 是否选中指定类型的控件
  704. function isControlSelected(tag){
  705. if (eWebEditor.document.selection.type == "Control") {
  706. var oControlRange = eWebEditor.document.selection.createRange();
  707. if (oControlRange(0).tagName.toUpperCase() == tag) {
  708. return true;
  709. }
  710. }
  711. return false;
  712. }
  713. // 改变编辑区高度
  714. function sizeChange(size){
  715. for (var i=0; i<parent.frames.length; i++){
  716. if (parent.frames[i].document==self.document){
  717. var obj=parent.frames[i].frameElement;
  718. var height = parseInt(obj.offsetHeight);
  719. if (height+size>=300){
  720. obj.height=height+size;
  721. }
  722. break;
  723. }
  724. }
  725. }
  726. // 大文件内容自动拆分
  727. function splitTextField(objField, html) {
  728. var strFieldName = objField.name;
  729. var objForm = objField.form;
  730. var objDocument = objField.document;
  731. objField.value = html;
  732. //表单限制值设定,限制值是102399,考虑到中文设为一半
  733. //var FormLimit = 50000;
  734. //var FormLimit = 102399;
  735. var FormLimit = 1023990;
  736. // 再次处理时,先赋空值
  737. for (var i=1;i<objDocument.getElementsByName(strFieldName).length;i++) {
  738. objDocument.getElementsByName(strFieldName)[i].value = "";
  739. }
  740. //如果表单值超过限制,拆成多个对象
  741. //if (html.length > FormLimit) {
  742. if (false) {
  743. objField.value = html.substr(0, FormLimit) ;
  744. html = html.substr(FormLimit) ;
  745. while (html.length > 0) {
  746. var objTEXTAREA = objDocument.createElement("TEXTAREA") ;
  747. objTEXTAREA.name = strFieldName ;
  748. objTEXTAREA.style.display = "none" ;
  749. objTEXTAREA.value = html.substr(0, FormLimit) ;
  750. objForm.appendChild(objTEXTAREA) ;
  751. html = html.substr(FormLimit) ;
  752. }
  753. }
  754. }
  755. // 远程上传
  756. function remoteUpload() {
  757. if (sCurrMode=="TEXT") return;
  758. var objField = document.getElementsByName("eWebEditor_UploadText")[0];
  759. splitTextField(objField, getHTML());
  760. divProcessing.style.top = (document.body.clientHeight-parseFloat(divProcessing.style.height))/2;
  761. divProcessing.style.left = (document.body.clientWidth-parseFloat(divProcessing.style.width))/2;
  762. divProcessing.style.display = "";
  763. eWebEditor_UploadForm.submit();
  764. }
  765. // 远程上传完成
  766. function remoteUploadOK() {
  767. divProcessing.style.display = "none";
  768. if (bDoneAutoRemote){
  769. doSubmit();
  770. }
  771. }