I am inserting a piece of code to the Page, when a ribbon named "Insert Code" which is present in the ribbon is clicked. Here is the code i use:

    <script type="text/javascript">//<![CDATA[
            function Warn()
            var href = '<div class="my-class"><h1>The Header</h1><p>The paragraph of text</p>';

       var range = RTE.Cursor.get_range();
                 var selection = range.parentElement();
                 if (!selection) {
                 var span = selection.ownerDocument.createElement('span');
                 span.innerText = href;


I am able to add the code on the page. But its inserted as below, rather than the actual html tags. Any info on how can i get it corrected?

&lt;div class=&quot;my-class&quot;&gt;         &lt;h1&gt;The Header&lt;/h1&gt;         &lt;p&gt;The paragraph of text&lt;/p&gt;         &lt

1 Answer 1


Try setting span.innerHTML instead:

span.innerHTML = href;
  • Got a query in between, once the "piece of code" as per the question above got inserted to the text editor, the cursor is getting disappeared. any way to get is available after the code which i have placed?
    – Scarlet959
    Oct 11, 2017 at 11:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.