In our example, we have a DIV denoted by ID “mydiv”.
And we have a hidden textarea denoted by the ID “myhidta”.
So, use a button place some where in your page (or preferably just below the DIV), to let the users click on the button, which then copies the text within the DIV onto CLIPBOARD, so users can then paste the text onto a notepad or other text editors.
Please note this works only in Internet Explorer. In FireFox , you need to add an extra line of code, that is to set the “signed.applets.codebase_principal_support” variable of the FireFox’s config to true. The code below detects if a browser is Firefox, if so then does the setting to TRUE. Add the two lines below at the beginning of the copy2cb() function shown above.
Or alternatively, you can set the Firefox browser to accept copying to clipboard, by changing the Firefox config manually. Just type “about:config” at the address bar of the Firefox, it will then present you with a screen for the confirmation if you wanna proceed for changing the config. Just click “I’ll be careful, I promise!”, then proceed, and you’ll be shown with a page full of the Firefox’ environment variables, then trace down according to the alphabetical order and locate where the variable “signed.applets.codebase_principal_support” is, double click on the line to set it to TRUE. (Double click again if you wanna reset it back to FALSE).