I am creating a custom WYSIWYG using editable iframe.I want to add a Custom html tag <ino> to a selected text like <info>some content here</info>.I have used this code
Editor = document.getElementById('iframe_id').contentWindow.document;
var tag='info'
var range = Editor.selection.createRange();
if (range.pasteHTML)
{
var content=Editor.selection.createRange().htmlText
content1="<"+tag+">"+content+"</"+tag+">"
range.pasteHTML(content1);
}
This code is for IE.In content1 am getting the correct text.But in output, the starting tag <info> is not getting .I have created the element using document.createElement('info');How i can solve this problem.Thanks in advance.
There is no HTML
<info>element. This could well be the reason that your code is not working.If you really need to do this (I can’t see why you would), you could take advantage of the fact that IE allows you to create invalid DOM elements using
document.createElement()and do something like the following, which pastes in a marker element, positions an<info>element containing the original TextRange content before the marker element and then removes the marker: