Google Groups Home
Help | Sign in
pasteHTML for Firefox?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Geevaa  
View profile
 More options May 9, 11:40 pm
From: Geevaa <govivasa...@gmail.com>
Date: Fri, 9 May 2008 20:40:23 -0700 (PDT)
Local: Fri, May 9 2008 11:40 pm
Subject: pasteHTML for Firefox?
Hi All,

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

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.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Phill-X  
View profile
(2 users)  More options May 22, 8:16 am
From: Phill-X <gllphill...@gmail.com>
Date: Thu, 22 May 2008 05:16:57 -0700 (PDT)
Local: Thurs, May 22 2008 8:16 am
Subject: Re: pasteHTML for Firefox?
At last  after trying hard I was able to build you a good sample code
that will run on both IE and Firefox

this is it.

<html>
<body>
<script language="JavaScript">
function function1() {

        if (document.selection && document.selection.createRange) {
                var myRange = document.selection.createRange();
                var m = myRange.pasteHTML('<p>Hello World</p>');
        }
        else if (window.getSelection) {
                var selection = window.getSelection();
                var range = window.getSelection().getRangeAt(0);
                range.deleteContents();
                var repl=document.createTextNode('Hello World');
                var newP = document.createElement('p');
                newP.appendChild(repl);
                range.insertNode(newP);
        }

}

</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>

On May 10, 8:40 am, Geevaa <govivasa...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google