0
我試圖創建一個使用的designMode /的execCommand一個非常簡單的和光所見即所得的編輯器,例如,當默認段落:如何使用的designMode
$(document).ready(function() {
wysiFrame.document.designMode = 'On';
});
<iframe name="wysiFrame" id="wysiFrame"></iframe>
當我在iframe中輸入文本它不裹任何標籤。當我打回了新的生產線被包裹在一個div,如:
here's my bit of text
<div>and this is the text after hitting return</div>
如果我添加:
$('#wysiFrame').contents().find("body").append('<p>Select me and type</p>');
,然後選擇文本並在鍵入標籤添加(在Chrome中至少)如預期的那樣,新的段落和換行符。
我想:
$('#wysiFrame').contents().find("body").append('<p></p>');
但是,這給了我:
My typed text
<p></p>
有沒有辦法段落標記內換行輸入的文本?我在網上搜索,但只能找到防止換行符參考段落標籤的參考。 歡迎所有幫助,建議和想法。 在此先感謝。