Copy content to clipboard compatible browser with js_javascript tips
If you want to copy content to the clipboard through js, it is not difficult at first. However, if you consider the browser compatibility issue, it becomes a bit troublesome. Using jquery-zclip to copy is a good choice. Use flash to achieve browser compatibility. . I won’t go into details about the principle, but let’s talk about how to implement it.
For example, my html code is as follows:
A total of two js files are required, not to mention jquery , and then there are jquery-zclip.js and ZeroClipboard.swf. These two files can be downloaded on the official website at the following address: http://www.steamdev.com/zclip/
Generate copy button js is as follows
This enables cross-browser copying. It’s not a difficult thing to do. It went smoothly when I tested it. But when I put it into the project, something went wrong. There was no flash where the copy button was generated. , only text. Later, I found out that the flash was actually generated, but not where the text was. It may have something to do with the iframe structure used in the background of my project. I guess this is a bug of this plug-in. After checking a lot of information, there was People said that the code needs to be changed, and then I changed it and it worked.
The code that needs to be modified is as follows
getDOMObjectPosition: function (obj, stopObj) {
// get absolute coordinates for dom element
var info = {
left: 0,
top: 0,
width: obj.width ? obj.width : obj.offsetWidth,
height: obj.height ? obj.height : obj.offsetHeight
} ;
if (obj && (obj != stopObj)) {
//info.left = obj.offsetLeft; //Before modification
//info.top = obj.offsetTop; / /Before modification
jpos = $(obj).position(); //After modification
info.left = jpos.left; //After modification
info.top = jpos.top; //After modification After
}
return info;
}
Actually, this is related to the principle of this plug-in. He covers the button with a transparent flash. If the two of them do not overlap, the above problem will arise.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



View macOS Clipboard History from Finder When you copy anything on your Mac (text, images, files, URLs, etc.), it goes to the Clipboard. Here's how to see what was last copied on your Mac. Go to Finder and click "Edit" in the menu bar. Click "Show Clipboard". This will open a window showing the contents of the macOS clipboard. Get Clipboard History Containing Multiple Items in Mac Of course, native Mac Clipboard History isn't the most versatile tool you can have. It only shows the last thing you copied, so if you want to copy multiple things at once and then paste them all together, you simply can't do that. However, if you are looking for

Check your keyboard If keyboard shortcuts don't work, there may be an issue with the keyboard itself. Make sure it is plugged in correctly and recognized by your PC. Have a laptop keyboard giving you trouble? If you have an extra keyboard, plug it in and see if it works. If so, it may be an issue with the keyboard itself. Using a wireless keyboard? Follow the manufacturer's instructions to re-pair. You should also check any cables for damage and make sure the keys are free of debris and pressed properly. For more information, check out these fixes for broken Windows 11 keyboard. Using the Print Screen Key If you desperately need a screenshot and don't have time to troubleshoot, you can use the workaround first. For a full photo of the desktop, click

Where is the clipboard on iPhone? Since iOS is a closed ecosystem, the clipboard is an internal feature stored in virtual memory. By default, users cannot view the clipboard contents or edit them in any way. However, there are some ways to access the clipboard on iPhone. You can paste the clipboard into the Notes application (or any other text editor) and keep multiple copies of the clipboard there, editing them as needed. Alternatively, you can use the Shortcuts app to create a shortcut that displays the clipboard. Finally, you can use a third-party application such as Paste. How to access the clipboard on iPhone? Whether you prefer to use the built-in Notes app,

Copying has always been a great way to save and share files. It allows you to create manual backups, perform simple transfers, and even make modifications that might damage the original file if not copied. However, this can sometimes be difficult if you have problems trying to use the clipboard on your Windows PC. Some Windows 11 users have recently been unable to use copy-paste on their systems. This issue can occur due to a number of reasons and if you are in the same boat, then you can fix it on your PC. How to Fix Copy-Paste on Windows 11 Since there are many issues that can cause copy-paste to malfunction on Windows, we have listed the most common solutions to fix this problem below. We recommend that you start with the first

We users should be able to understand the diversity of some functions when using this platform. We know that the lyrics of some songs are very well written. Sometimes we even listen to it several times and feel that the meaning is very profound. So if we want to understand the meaning of it, we want to copy it directly and use it as copywriting. However, if we want to use it, we still need to You just need to learn how to copy lyrics. I believe that everyone is familiar with these operations, but it is indeed a bit difficult to operate on a mobile phone. So in order to give you a better understanding, today the editor is here to help you. A good explanation of some of the above operating experiences. If you also like it, come and take a look with the editor. Don’t miss it.

<h2>Using Clipboard History on Windows 11</h2><p>You can still use <strong>right-click>copy</strong> and <strong>right-click> Paste </strong> or use <strong>Ctrl+C</strong&

Where are clippings and screenshots in Windows 11? This is a question we get from some of our readers who may have just installed a new operating system or used a snipping tool for the first time. This tool is designed to capture any or all parts of your computer screen. To put things in context, the PrintScreen key will take a complete snapshot of your screen, but the SnippingTool can be adjusted to grab just the area you like. Where are screenshots and screenshots on Windows 10/11? By default, clippings and screenshots are saved to your computer's clipboard. This means that to retrieve them you simply paste them into your desired application such as Microsoft Paint, Photo

The shortcut key for copying is "Ctrl+c", and the corresponding paste key is "Ctrl+v"; on the computer, use the mouse to drag and select text, hold down Ctrl, and then click the C key to complete the copy; A shortcut key refers to completing an operation through certain specific keys, key sequences, or key combinations.
