In unserer Anwendung verwenden wir die folgende Logik, um HTML (Text und Format) in die Zwischenablage zu kopieren.document.execommand ("copy") funktioniert nicht mehr in Internet Explorer 11
function copy(element_id)
{
var aux = document.createElement("div");
aux.setAttribute("contentEditable", true);
aux.innerHTML = document.getElementById(element_id).innerHTML;
aux.setAttribute("onfocus", "document.execCommand('selectAll',false,null)");
document.body.appendChild(aux);
aux.focus();
document.execCommand("copy");
document.body.removeChild(aux);
console.log("COPY");
}
<p id="demo"><b>Bold text</b> and <u>underlined text</u>.</p>
<button onclick="copy('demo')">Copy To Clipboard Keeping Format</button>
Es funktioniert in allen gängigen Browsern (Chrome, Firefox, Kanten- und Internet Explorer) in Ordnung.
Mit dem neuesten Internet Explorer Version 11.125.16299.0 (Updateversion: 11.0.49 - KB4052978) wird der HTML-Code nicht mehr in die Zwischenablage kopiert.
Es ist eine Sicherheitseinstellung für diese unter:
Options -> Security -> Edit level ... -> Scripting -> Allow access to clipboard
ich den Wert von „Ask“ auf „Aktiviert“. Dies hat keine Auswirkung.
Weiß jemand, warum, was sie geändert haben und vielleicht eine andere Lösung oder Workaround? Vielen Dank.