pasteHTML for Firefox?

G

geevaa

Hi All,


Try the example javascript given in this link in IE and Firefox.
http://www.java2s.com/Code/JavaScript/Node-Operation/pasteHTMLExample.htm



<html>
<body>
<script language="JavaScript">
function function1() {
var myRange = document.selection.createRange();
var m = myRange.pasteHTML('<p>Hello World</p>');
}
</script>
<p>Highlight a part of this text, then click button below</p>
<input id="myB" type="button" value="Click me" onclick="function1();">
</body>
</html>





Its works only in IE and not in Firefox.
Is there is any Firefox equivalent coding to achieve the same
functionality which is working good in IE?

Thanks in advance.
 
B

Bart Van der Donck

geevaa said:
<html>
<body>
<script language="JavaScript">
function function1() {
var myRange = document.selection.createRange();
var m = myRange.pasteHTML('<p>Hello World</p>');}

</script>
<p>Highlight a part of this text, then click button
below</p>
<input id="myB" type="button" value="Click me" onclick="function1();">
</body>
</html>

Its works only in IE and not in Firefox.
Is there is any Firefox equivalent coding to achieve the
same functionality which is working good in IE?

The problem is that 'document.selection.createRange' is not supported
everywhere. Martin Honnen wrote an elegant approach:

http://www.faqts.com/knowledge_base/view.phtml/aid/32427

Hope this helps,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top