0

I want to insert some html into the page.

document.execCommand('insertHTML', false, "<a href=\""+ url + trackingParam + "\">"+ url + "</a>")

This command works fine in Chrome. But, I did some search, it seems like insertHTML is not supported by IE 11.

I am wondering if there is a equivalent solution for IE 11.

Thanks!

Taplar
  • 24,788
  • 4
  • 22
  • 35
kevin
  • 419
  • 1
  • 3
  • 11
  • 1
    https://stackoverflow.com/questions/3398378/execcommandinserthtml-in-internet-explorer – EGC Oct 08 '19 at 20:42
  • Could always do `document.body.innerHTML += 'more html'` – Taplar Oct 08 '19 at 21:04
  • @Taplar Thanks! I tried your comment, but it doesn't work. Your command is not equivalent with mine, It will insert the content to the outside of the div... – kevin Oct 08 '19 at 21:11
  • 1
    If you want it in the div, then you just need to select the div first, then do the innerHTML += off of that. https://jsfiddle.net/e29z1pow/ – Taplar Oct 08 '19 at 21:15
  • Possible duplicate of [execCommand("insertHTML", ...) in Internet Explorer](https://stackoverflow.com/questions/3398378/execcommandinserthtml-in-internet-explorer) – Jorge Fuentes González Oct 08 '19 at 21:33
  • @Taplar, I find that your suggestion can solve the issue. I suggest you to post your solution as an answer. – Deepak-MSFT Oct 09 '19 at 03:02

0 Answers0