This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How to select all text in a textbox and copy it to clipboard using JavaScript/jQuery?
Copy text to the client’s clipboard using jQuery
I need a javascript, jquery function for copy to clipboard functionality. I know following code but it works in IE only:
holdtext.innerText = copytext.innerText;
Copied = holdtext.createTextRange();
Copied.execCommand("Copy");
I see some tutorials which are suggestion some swf files. I have used some of them like http://www.steamdev.com/zclip/ but it is not working.
Please suggest solution to it.
There isn't any cross-browser way to copy data to the clipboard via javascript (it's regarded as a security hole) - it can be done with the assistance of a small flash applet, but this of course isn't fully cross platform.
One of the cheats I've used before is to create a prompt with a default value in which makes it slightly easier for the user to copy-and-paste the information without having to highlight it in the page. But this doesn't really solve the problem. All you can do is make the copy-and-paste as little effort as possible.
The mainstream way of doing this is via a SWF object. ZeroClipboard is a neat project which deals with this.
Related
I'm using a Crawler4j and Jsoup to crawl a website and it works fine for the HTML text, but there are some important contents, which default values are hard coded in CSS and then dynamically set with JavaScript.
For example, I have the
and I need the width value, which in CSS is hard coded as 10px, but modified in JavaScript to, let's say, 5px.
Is there a way to get this value without using another crawler? Or a simple alternative?
I have already quite a lot of code, so I don't want to rewrite everything if there is a possibility to do that with the Crawler4j.
I hope my question is clear enough and thank you in advance for your help!
This is not possible with crawler4j nor with jsoup. They both handle only static HTML content.
There are several open issues related dynamic JavaScript execution on the official GitHub Repository: #49, #197 and #220.
To achieve your objectives, you would need to build a stack based on Selenium, CasperJS and/or PhantomJS, which could then be used for advanced crawling including JavaScript execution.
This question already has answers here:
How to handle JavaScript being disabled in AngularJS
(2 answers)
Closed 8 years ago.
I have learned angular.js, and it's awesome , i'm impressed. i want to use it in my website, but what if our some of user has disabled JavaScript on there browser, they should still gonna see my website content ?????. i'll appreciate your help.
In most cases when js is required, you should add noscript which will be displayed when js is disabled. In that tag you need to warn user that he/she should enable js.
In addition to other answer, I am quoting from Angular book:
Not everyone’s browser supports JavaScript. Let everyone see all of your content and use your app without needing to execute code in the
browser.
The world has changed since these concepts were born. Point #1 is no
longer true for any interesting population. If you’re running a
browser without JavaScript, you’re rele‐ gated to sites created in the
1990s
Or make a div with a warning/notice text (maybe in center of page), and hide that div in js (first thing in your code)
So, if the user does not have js enabled, they will see the nice warning
This question already has answers here:
can view source be disabled by a website?
(6 answers)
Closed 8 years ago.
Actually I want to protect my source code of my website from everybody.
so I want to disable all sources of finding the code like: Ctrl+U, Ctrl+Shift+I,F12 and menu of browser.
It is impossible to hide your source code. You could install a script to prevent right-clicking or encrypt your code with JavaScript, but that won't stop anyone that knows anything about web development from finding it.
This will never work, and your effort is better spent elsewhere.
At the very least, a user can use a web proxy like Fiddler to easily retrieve the source code.
This question already has answers here:
Is there a way to use Canvas in IE7 or IE8?
(3 answers)
Closed 8 years ago.
I'm having a very specific problem with IE7 and I'd appreciate any insight anyone might have.
I need to be able to add text taken from the user and add it to an image so that image and text are a single image file easily saveable by the user. I've figured out how to do this using HTML5, but this needs to work in IE7 and IE8. Furthermore, this needs to work offline, client side, and without any third party browser plugins like Flash.
I realize this is a doozy. I've spent weeks on it myself, but the powers that be aren't taking "no" for an answer on this one. Please help!
You might want to try using processing.js, which probably needs some tweaks on IE7.
Or RaphaelJS which uses vector graphics and allegedly works "out-of-the-box" for IE7.
This question already has answers here:
How to hide html source & disable right click and text copy?
(21 answers)
Closed 9 years ago.
I wonder how to hide the source code of a web page. This is an example of webpage with hidden source (right click -> view page source). Any ideas or suggestions?
UPDATE I fully agree, that fully hiding HTML source is impossible, otherwise the browser could't parse it. Using tools like FireBub etc. will show you the source. The interesting in the example above in that on "show source code" the displayed page does not match the output.
Now I understand it is just another kind of technology used here - XSLT.
Thanks for your replies!
If your page is generated dynamically (by Javascript), then it using View Source will not show anything (or very little, anyway). I suspect that's how your example is doing it.
Bear in mind that any page generated this way will still be visible by using a code inspector such as Firebug. So as #Brad M says, this will only stop people who don't really know what they're doing.
If you build the entire page in Java or Flash (or something similar like Silverlight I guess) then it's a lot harder for someone to find out what the source code is (though Java is pretty easy to decompile)
There is no way to hide your code from a client that must execute the code.
Your example just did some trick to prevent right-clicking and stuff. But eventually you can get your way around.
For interpreted language such as javascript, the following adage is true.
" Lock on the door is only for the one who don't care. If there comes thief, most of the time he is already prepared."
All you can do to prevent is obfuscating your code. That will prevent it for some time. But remember, if they are going to crack it, it is not unstoppable. The basic thing to remember is: your script is going to run on the client side and is "INTERPRETED" by browser. In these days, when there are few tools that can create source code from compiled file, the thought of hiding javascript code is even not thinkable. This How can I obfuscate (protect) JavaScript? can help you on how to do it.