?
Solved

JavaScript Code does not work in all browsers

Posted on 2013-02-05
9
Medium Priority
?
278 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 1000 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 83

Expert Comment

by:Dave Baldwin
ID: 38866380
Try the sample code in the Mozilla link above.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:APD_Toronto
ID: 38866420
i don't understand
0
 
LVL 83

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 83

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

Video: Liquid Web Managed WordPress Comparisons

If you run run a WordPress, you understand the potential headaches you may face when updating your plugins and themes. Do you choose to update on the fly and risk taking down your site; or do you set up a staging, keep it in sync with your live site and use that to test updates?

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
This Micro Tutorial will demonstrate how to add subdomains to your content reports. This can be very importing in having a site with multiple subdomains.
Suggested Courses

771 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