473,511 Members | 16,252 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

pasteHTML for Firefox?

Hi All,
Try the example javascript given in this link in IE and Firefox.
http://www.java2s.com/Code/JavaScrip...TMLExample.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.


Jun 27 '08 #1
1 2121
geevaa wrote:
<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/...html/aid/32427

Hope this helps,

--
Bart
Jun 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2703
by: Simon Wigzell | last post by:
I'm using a 3rd party (htmlarea) WYSIWYG html editting tool. it works great most of the time. I have a problem where I've made my own function to create a bookmark type link. e.g. I want to turn...
2
1951
by: colinhumber | last post by:
I'm running this line of code: oTarget.pasteHTML(formattedHtmlText); where oTarget is a text range object. When formattedHtmlText is, say, "<STRONG><BUTTON...
10
4063
by: colinhumber | last post by:
I'm running this line of code: oTarget.pasteHTML(formattedHtmlText); where oTarget is a text range object. When formattedHtmlText is, say, "<STRONG><BUTTON...
87
9495
by: expertware | last post by:
Dear friends, My name is Pamela, I know little about CSS, but I would like to ask a question I have an image on a web page within a css layer: <DIV ID=MyLayer STYLE = "position:...
14
2298
by: expertware | last post by:
Ok! to avoid confusion I will start a new argument. Thanks!! FIREFOX 1.0.7 AND IE6 viewed through DATATIME: a summary REPORT ===============================================================...
5
3106
by: SPE - Stani's Python Editor | last post by:
Hi, During optimizing SPE for Ubuntu, I found something strange. I have Ubuntu 5.10 "The Breezy Badger" and unfortunately this code is not working: >>> import webbrowser >>>...
5
3870
by: Jason | last post by:
Hi, I'm developing an HTML Editor Control using VB.Net 2003 for an application that used to use the DHTML Editor Control that is no longer supported. Well, it's been fun but I've hit a wall with...
7
9580
by: Coder | last post by:
Hi I have the following code in java script, it is not giving proper output in FIREFOX but running fine in IE... can anybody help me out to make this run in FIREFOX . <script...
16
3689
by: markjavascript | last post by:
Hi, In an editable div, I inserted a big letter, Rng.pasteHTML("<font size=5>A</font>");,fine. However, after that, when type in other letters, (sometimes) I got big letters with size=5. Here...
0
7353
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7418
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7075
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7508
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5662
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5063
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3222
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3212
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
781
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.