


Copy the js code of the Input content_Support all browsers, fix the problem of Firefox3.5 and above_javascript skills

But two lines of JS code are enough for IE6, and it is similar for IE7 and above. The only difference is that the security prompt is disgusting. If users see it, they must be suspicious;
But even Firefox, Chrome, etc. You are not allowed to copy;
I remember that there were codes in this area on the Internet before. I searched and found that they cannot be used in Firefox 3.5 or above. Finally, I found one. The code is quite complicated, so I don’t dare. use.
Finally, I really had no choice but to check the information and wrote one myself:
A few main points to understand:
1. For browsers such as Firefox, for security reasons, just use them directly Copying is not allowed;
2. In Flash, you can use System.setClipboard() to throw the content to the clipboard, and then let FLASH work under Firefox;
3. In Flash Player 10.0 Later, for security reasons, the content of System.setClipboard must be in FLASH;
4. ExternalInterface can be used to communicate with JS;
5. ExternalInterface must be quoted in flash8;
Default HTML code:
So, when designing, make the first judgment first. If it is IE, just use the default code, which is the least problematic. , if not, use a FLASH to overwrite the default button;
if (window.XMLHttpRequest){//If it is not IE, copy it in FLASH
$('buttonBox').innerHTML = '
The following are all the JS files:
<script> <br>function $(id){ <br>return document.getElementById(id); <br>} <br>function copy(){ //ie6 <br>var value = $('testInput').value; <br>window.clipboardData.clearData(); <br>window.clipboardData.setData("Text", value); <br>alert( 'Copy successfully! '); <br>} <br>function flashCopy(){//firefox ....... <br>return $('testInput').value; <br>} <br>function flashCopyBack(){ <br>alert('Copy successfully!'); <br>} <br>if("v" != "v"){//If it is not IE, use FLASH to copy <br>$(' buttonBox').innerHTML = '<embed src="111.swf" width="48" height="23" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type ="application/x-shockwave-flash"></embed>'; <br>} <br></script>
The code of the FLASH button is as follows:
on (release) {
import flash.external.ExternalInterface;
var inputText = ExternalInterface.call('flashCopy');
System.setClipboard(inputText);
ExternalInterface.call('flashCopyBack');
//_root.boboText.text = inputText;
}
The principle is to avoid the security restrictions. When clicking the button in FLASH, use the code in FLASH to adjust the JS code in the page. The JS code can get the INPUT and then pass it to FLASH. At this time, there are these values in FLASH. Then, FLASH itself saves these values to the clipboard through System.setClipboard; then, he calls the page. flashCopyBack, flashCopyBack only does one thing, which is to prompt that the copy has been successful!
I have tested it in Firefox, Chrome, and IE, and there is no problem. If anyone finds any problem, please tell me, thank you, because I have started using it now!
Please indicate the source for reprinting: Zi Mouse

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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

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

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.

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.

In the PS copy layer shortcut keys, we can know that if you want to copy a layer when using PS, you can use the shortcut key [Ctrl+J] for quick copying. This introduction to the shortcut keys for copying layers can tell you the specific operation method. The following is the detailed content, so take a look. PS copy layer shortcut key answer: [Ctrl+J] Specific method: 1. Open the image in PS and select the layer that needs to be copied. 2. Press [Ctrl+J] on the keyboard at the same time to complete the copy of the layer. Other copying methods: 1. After opening the image, press and hold the layer and move the [New Layer] icon downwards. 2. After moving to the icon, let go. 3. The layer copy is completed.

Preparation Use vuecreateexample to create a project. The parameters are roughly as follows: use native input. Native input is mainly value and change. The data needs to be synchronized when changing. App.tsx is as follows: import{ref}from'vue';exportdefault{setup(){//username is the data constusername=ref('Zhang San');//When the input box changes, synchronize the data constonInput=;return( )=>({

How to implement the laravel input hidden field: 1. Find and open the Blade template file; 2. Use the method_field method in the Blade template to create a hidden field. The creation syntax is "{{ method_field('DELETE') }}".

Vue is a popular JavaScript framework that provides a convenient drag-and-drop function, allowing us to easily copy and move elements. Next, let's take a look at how to copy and move drag-and-drop elements in Vue. 1. Basic implementation of drag-and-drop elements To copy and move drag-and-drop elements in Vue, you first need to implement the basic drag-and-drop function of the element. The specific implementation method is as follows: Add the elements that need to be dragged in the template: <divclass="drag-elem"

On Windows, the shortcut key for copying is Ctrl C; on Apple, the shortcut key for copying is Command C; on Linux, the shortcut key for copying is Ctrl Shift C. Knowing these shortcut keys can improve the user's work efficiency and facilitate text or file copy operations.

How to back up CMS DreamWeaver database files? In the process of using CMS to build a website, it is very important to ensure the security of database files to prevent data loss or damage. Backing up database files is an essential operation. The following will introduce how to back up CMS DreamWeaver database files and attach specific code examples. 1. Use phpMyAdmin for backup. phpMyAdmin is a commonly used database management tool through which you can easily back up the database. The following is using phpMyAdm
