Home >
Web Front-end >
JS Tutorial >
The perfect solution to copy text with one click, compatible with all browsers_javascript skills
The perfect solution to copy text with one click, compatible with all browsers_javascript skills
WBOY
Release: 2016-05-16 17:30:00
Original
1279 people have browsed it
Click the js to copy the text. I have been looking for it for a long time. Since I have never been in contact with it before, I have no idea that it is compatible with IE and standard DOM browsers. It not only requires js, but also requires the help of flash. clipboard.swf is available for download online.
ie allows access to the clipboard. window.clipboardData has access to but is standard dom. I read some articles that all use flash settings to hide. But flash10 does not support it. However, there is another method that is feasible. Just record it. The following method supports standard DOM.
if (window.clipboardData) { window.clipboardData.setData("Text",pStr); Util.successHide(); }
Finally, this can realize single-click copying of text and is compatible with all browsers device. remember. The path of swf must be correct! If it is wrong, the hand shape will not appear. This is a characteristic.
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn