Solved

JavaScript Code does not work in all browsers

Posted on 2013-02-05
9
270 Views
Last Modified: 2013-02-08
Hi Experts,

I have the code below working in IE, but not in Fireiox and Chrome. Can anyone tell me why and how to fix it?

Thank you

<html>

<body>

<input type="text" id="txt" value="abcdef...xyz">

<input type="BUTTON" onClick="ClipBoard()" value="Copy to Clipboard" >

<TEXTAREA ID="holdtext" STYLE="display:none;">
</TEXTAREA>

</body>


<SCRIPT LANGUAGE="JavaScript">

    function ClipBoard() {
        holdtext.innerText = txt.value;
        Copied = holdtext.createTextRange();
        Copied.execCommand("Copy");
    }

</SCRIPT>



</html> 

Open in new window

0
Comment
Question by:APD_Toronto
  • 5
  • 4
9 Comments
 
LVL 82

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 38856383
It looks like your code is not correct or complete enough.  See here for Mozilla / Firefox info: https://developer.mozilla.org/en-US/docs/Rich-Text_Editing_in_Mozilla#Executing_Commands
0
 

Author Comment

by:APD_Toronto
ID: 38866343
so, how can i make my code work in both, IE and FF?
0
 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 38866380
Try the sample code in the Mozilla link above.
0
 

Author Comment

by:APD_Toronto
ID: 38866420
i don't understand
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 38866475
This page https://developer.mozilla.org/en-US/docs/Rich-Text_Editing_in_Mozilla#Executing_Commands includes a complete Rich-Text editor at the bottom of the page that includes the command you are trying to use.  Make up a test page and try their code.
0
 

Author Comment

by:APD_Toronto
ID: 38866501
I'm not doing any rich-text editting, i just need to copy to clipboard, as per my code above
0
 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 38866638
Did you look at that page and how they are using the commands to copy to the clipboard?
0
 

Author Comment

by:APD_Toronto
ID: 38866718
I can't see it.  Can you paste the code here please
0
 

Author Closing Comment

by:APD_Toronto
ID: 38868966
could not figure out
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now