JavaScript Paste HTML at caret without using insertNode paste html at caret

I have the following method to paste some HTML at the caret position, using `range.insertNode(), sourced from this SO answer

function insertAtCursor(html) {
    var sel, range;
    if (window.getSelection) {
        // IE9 and non-IE
        sel = window.getSelection();
        if (sel.getRangeAt && sel.rangeCount) {
            range = sel.getRangeAt(0);
            range.deleteContents();

            var el = document.createElement("div");
            el.innerHTML = html;
            var frag = document.createDocumentFragment(), node, lastNode;
            while ((node = el.firstChild)) {
                lastNode = frag.appendChild(node);
            }
            range.insertNode(frag);

            // Preserve the selection
            if (lastNode) {
                range = range.cloneRange();
                range.setStartAfter(lastNode);
                range.collapse(true);
                sel.removeAllRanges();
                sel.addRange(range);
            }
        }
    } // non IE code removed
}

This is for a Windows Store app. I've discovered a bug in Universal Apps for Windows 8.1 where a serious typing lag occurs after a paste event using range.insertNode(). The issue only occurs in Windows 8.1 Universal Apps running under Windows 10. I can't replicate the issue under Windows 8.1 (although I definitely have experienced it in the past on Win8.1) - but it happens every time on Windows 10 on several machines using this sample app

https://onedrive.live.com/redir?resid=EE99EF9560A6740E!230777&authkey=!ACBcfSH4H1BE1s8&ithint=file%2czip

Does anyone know another way to paste HTML at the caret without using range.insertNode()? Windows Store apps using the IE11 rendering engine, so if it works in IE11 it will work in a Store App / Universal App

Answer:1

I mostly see JavaScript use classes as a constructor as following: class Rectangle { constructor(height, width) { this.height = height; this.width = width; } // Getter get area() { ...

I mostly see JavaScript use classes as a constructor as following: class Rectangle { constructor(height, width) { this.height = height; this.width = width; } // Getter get area() { ...

  1. what is a national emergency
  2. whatsapp
  3. whataburger
  4. what time is it
  5. what is my ip
  6. what song is this
  7. what is a state of emergency
  8. what is a dry cough
  9. what happens in a national emergency
  10. what is the stafford act
  11. what is a bear market
  12. what does ���� mean
  13. what to watch
  14. what stocks to buy today
  15. whataburger menu
  16. what is the weather
  17. what is rsv
  18. what is gluten
  19. what is pv
  20. what is a boomer

I'm creating a web using Bootstrap 3 and I'm using the page-content-wrapper script. When I collapse the page, logo of my web(left right corner in navbar) changes the position due to the padding that ...

I'm creating a web using Bootstrap 3 and I'm using the page-content-wrapper script. When I collapse the page, logo of my web(left right corner in navbar) changes the position due to the padding that ...

I have the following JavaScript object: var example = [{ country: "US", things: { weather: 'cloudy' } }, { country: "US", things: { resource: 'lead', weather:...

I have the following JavaScript object: var example = [{ country: "US", things: { weather: 'cloudy' } }, { country: "US", things: { resource: 'lead', weather:...

Currently I have the following partial code in my puppeteer file: const getImgSrc = await page.$eval('#ldpGallery', el => el.getElementsByTagName('img')); console.log(getImgSrc); The html I'm ...

Currently I have the following partial code in my puppeteer file: const getImgSrc = await page.$eval('#ldpGallery', el => el.getElementsByTagName('img')); console.log(getImgSrc); The html I'm ...

  1. puppeteer eval function