Este artículo describe el método de JS para implementar la compatibilidad de PasteHTML con IE, Firefox y Chrome. Compártelo para su referencia, como sigue:
<html> <body> <script language = "javaScript"> function test () {if (document.selection && document.selection.createrange) {var myRange = document.selection.createrGe (); var m = myRange.pastehtml ('<iframe width = 100 height = 100 src = "http: //localhost/t2.htm"> </iframe>'); } else if (window.getSelection) {var selection = window.getSelection (); var range = window.getSelection (). GetRanGeat (0); range.deletecontents (); var newp = document.createElement ('iframe'); newp.src = "http: //localhost/t2.htm"; newp.width = "100"; newp.height = "100"; range.insertNode (newp); }} </script> <p> Resalte una parte de este texto, luego haga clic en el botón a continuación </p> <input id = "myb" type = "button" value = "Click me" onClick = "test ();"> </body> </html>For more information about JavaScript related content, please check out the topics of this site: "Summary of JavaScript switching effects and techniques", "Summary of JavaScript search algorithm skills", "Summary of JavaScript animation effects and techniques", "Summary of JavaScript errors and debugging techniques", "Summary of JavaScript data structures and algorithm skills", "Summary of JavaScript Algoritmos y técnicas de recorrido ", y" Resumen del uso de operaciones matemáticas de JavaScript "
Espero que este artículo sea útil para la programación de JavaScript de todos.