Inserting custom html tag using javascript pasteHTML function -


i creating custom wysiwyg using editable iframe.i want add custom html tag <ino> selected text <info>some content here</info>.i have used 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 ie.in content1 getting correct text.but in output, starting tag <info> not getting .i have created element using document.createelement('info');how can solve problem.thanks in advance.

there no html <info> element. reason code not working.

if need (i can't see why would), take advantage of fact ie allows create invalid dom elements using document.createelement() , following, pastes in marker element, positions <info> element containing original textrange content before marker element , removes marker:

var range = editor.selection.createrange(); var info = editor.createelement("info"); info.innerhtml = range.htmltext; var id = "some_random_id"; range.pastehtml('<span id="' + id + '"></span>'); var span = editor.getelementbyid(id); span.parentnode.insertbefore(info, span); span.parentnode.removechild(span); 

Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -