This question already has answers here:
How do I copy to the clipboard in JavaScript?
(27 answers)
Closed 8 years ago.
I'm writing a code and I display to the user a table with data from DB.
The user can copy all the data manually, but I want to add a button that copy automatically the data to clipboard.
How can I do this?
Thanks!
You cannot do this with javascript.
There is no browser that can allow that. It's a security issue.
If you are good with JQuery, use this Library
P.S Although it raise a security concern, most of the browsers doesn't allow it.
Related
This question already has answers here:
How can I prevent javascript code theft?
(7 answers)
Closed 5 years ago.
I develop a small website now some of my friends asking to give us the code.so i want now to do a trick in my code that no one can copy or modify my code.if any one know's please post.
Copy: Forget it. If you give the code to someone, he can just copy and re-use it. Consider using an appropriate license for your code to make shure the receiver knows what he is allowed to do with your code
Changes: Use a version control system. As a developer you must learn to use at least one. Do it now. I recommend git, but there are plenty of VCS`ses available (svn,bazaar,cvs...)
This question already has answers here:
In Firefox, Write to a File using Javascript?
(4 answers)
Closed 7 years ago.
May I ask, is it possible to write local file via javascript using firefox.
Something like ActiveXObject("Scripting.FileSystemObject") in IE.
Thank you very much
Easy way is to send the file to Firefox as a download. So user can choose where to store this file.
Navigators can not act directly on local file system because of security implications!
This question already has answers here:
CSS: What does the question mark at the end of css do?
(7 answers)
What does "styles.css?=121" mean in this html code? [duplicate]
(2 answers)
Closed 8 years ago.
Why do use like this filename.css?2 or filename.js?4
What are those numbers after question mark?
I did research online but I didn't find any answer.
Thanks!
These are called cache busters.
Usually, when a browser downloads a file (CSS, JS, etc.) it caches it so that it doesn't have to download it later.
However, this is a problem when you decide to update your file, because the browser thinks it already has the latest version. To work around it, we use the cache busters. When you make a change to the file, you also change the number after the question marks, which tricks the browser into thinking this is a different file for which it doesn't have a cache it, and forces a re-download.
Sometimes JS scripts are created on the fly using server side technologies other times it is simply a version number to help with browser caching issues
This question already has answers here:
How to enable cookies via javascript
(3 answers)
Closed 8 years ago.
Is there any way to enable browser cookies using Javascript? I need to show the user data in the form page which has filled by the user earlier. Please get me some solution to show the data which has already submitted before in the form page.
This cannot be done as it would bring security issues.
This question already has answers here:
How do I copy to the clipboard in JavaScript?
(27 answers)
Closed 10 years ago.
I currently have a JSF webapp and I have an output field that my managed bean sets the value for, and I want to ass a button for the user to copy the output text straight to their clipboard (aka ctrl-c/cmd-c).
I've been doing some research, but I'm a bit confused, some are suggesting this cannot be done.
So my question is...can this be done? And if so, any suggestions on how to implement it?
Thanks!
Cannot be done using javascript alone. You can do it with a flash plugin though. Check out zeroclipboard: http://code.google.com/p/zeroclipboard/