I have been searching for the js that I have clicked to copy text for a long time. Since I have never touched on it before, I have no idea whether it is compatible with ie and standard dom browsers. I not only need to use js, but also need the help of flash, next we will share with you the specific implementation method. click Copy text js. I have been searching for a long time. Since I have never touched on it before, I have no idea whether it is compatible with ie and standard dom browsers. I not only need to use js, but also need the help of flash. Clipboard.swf is downloaded online.
Ie allows access to the clipboard. Window. clipboardData can be accessed
But standard dom. I have read some articles that use flash to hide the settings. However, flash 10 is not supported.
However, there is another method that is feasible, fixed record, the following methods support standard dom.
The Code is as follows:
(Function (){
Window ['util'] = {
CACHE :{},
GetText: function (){
Return Util. CACHE. CLIPBOARD_TEXT;
},
SuccessHide: function (){
Alert ("copy the recruitment email address of Beihai 365! ");
},
Copy: function (pStr, hasReturn, isdo ){
Var html = [];
Html. push ('');
Html. push ('');
Html. push ('');
Html. push ('');
Html. push ('');
Html. push ('');
Var yu = document. getElementById ('copy'). innerHTML;
Document. getElementById ('copy'). innerHTML = yu + html. join ('');
Util. CACHE. CLIPBOARD_TEXT = pStr;
}
}
Util. Copy ('zhaopin @ beihai365.com ');
})();
If you want to be compatible with ie. Add
The Code is as follows:
If (window. clipboardData ){
Window. clipboardData. setData ("Text", pStr );
Util. successHide ();
}
Finally, you can click to copy text and make it compatible with various browsers. Remember. Swf path must be correct! If it is not correct, it is a feature.
The Code is as follows:
(Function (){
Window ['util'] = {
CACHE :{},
GetText: function (){
Return Util. CACHE. CLIPBOARD_TEXT;
},
SuccessHide: function (){
Alert ("copy the recruitment email address of Beihai 365! ");
},
Copy: function (pStr, hasReturn, isdo ){
Var copy = document. getElementById ('copy ');
If (window. clipboardData ){
Copy. onclick = function (){
Window. clipboardData. setData ("Text", pStr );
Util. successHide ();
}
} Else {
Var html = [];
Html. push ('');
Html. push ('');
Html. push ('');
Html. push ('');
Html. push ('');
Html. push ('');
Var yu = copy. innerHTML;
Copy. innerHTML = yu + html. join ('');
Util. CACHE. CLIPBOARD_TEXT = pStr;
}
}
}
Util. Copy ('zhaopin @ beihai365.com ');
})();