javascript - how to change behavior of contenteditable blocks after on enter pressed in various browsers -
when pressing enter in <div contenteditable="true"> </div>
in firefox <br />
produced - that's ok. in chrome or ie new <div>
or <p>
created. should make chrome , ie behave firefox .
as douglas said earlier, browsers try clone previous tag when customer starts new paragraph on editable page. discrepancy occurs when browser has nothing depart - e.g. when page body empty. in case different browsers behave differently: ie starts wrap every string <p> tag, chrome wraps each line in <div>.
to increase cross-browser experience, webkit developers have introduced defaultparagraphseparator command. can use following javascript on page loading chrome change default paragraph separator <p> tag:
document.execcommand('defaultparagraphseparator', false, 'p');
Comments
Post a Comment