2010-11-20 70 views
0

我在我的網站中使用CLEditor,並且在使用IE時遇到問題。問題是:當您插入圖像並將其放入編輯器中,然後插入另一個圖像時,它將覆蓋prevoius圖像。使用Firefox,它會將新的一個放在旁邊。我聯繫了CLEditor,他告訴我這是一個瀏覽器問題。他讓我通過檢查IE來解決問題,然後在插入圖像後使用TextRange.collapse()方法將當前範圍摺疊到最後。我試圖做出這一點,但我不熟悉Javascript使其成爲可能。我需要你的幫助才能使其工作。execCommand在IE中的行爲:CLEditor映像覆蓋問題

這是用於將圖像插入到編輯器區域的代碼:

.bind(CLICK, function() { 

    // Insert the image or link if a url was entered 
    var $text = $popup.find(":text"), 
    url = $.trim($text.val()); 
    if (url !== "") 
    execCommand(editor, data.command, url, null, data.button); 

    // Reset the text, hide the popup and set focus 
    $text.val("http://"); 
    hidePopups(); 
    focus(editor); 

}); 

回答

0

這是此問題的解決方案。解決這個問題需要三天時間,因爲我不是JavaScript專家。我希望這將有所幫助。

 .bind(CLICK, function() { 

      // Insert the image or link if a url was entered 
      var $text = $popup.find(":text"), 
      url = $.trim($text.val()); 
      if (url !== "") 
      execCommand(editor, data.command, url, null, data.button); 

      // Reset the text, hide the popup and set focus 
      $text.val("http://"); 
      hidePopups(); 
      if ($.browser.msie) { 
    var editorvalue=editor.$frame[0].contentWindow; 
    var pos = editorvalue.document.body.innerHTML.length; 
    var textRange = editorvalue.document.body.createTextRange(); 
    textRange.collapse(true); 
    textRange.moveEnd("character", pos); 
    textRange.moveStart("character", pos); 
    textRange.select(); 


    } 

      focus(editor); 

     });