jsがクリップボードにテキストをコピーします

        関数copyToClipboard(テキスト){
             場合(text.indexOfは( ' - ')== -1!){ 
                編曲しましょう = text.split( ' - ' ); 
                テキスト = [0] + ARR ARR [1 ]。
            } 
            のVaRにtextArea =のdocument.createElement( "TEXTAREA" )。
            textArea.style.position =「固定」
            textArea.style.top = '0' ; 
            textArea.style.left = '0' ; 
            textArea.style.width = '2EM' ; 
            textArea.style.height = '2EM' ;= '0' 
            textArea.style.border = 'なし' ; 
            textArea.style.outline = 'なし' ; 
            textArea.style.boxShadow = 'なし' ; 
            textArea.style.background =「透明」
            textArea.value = テキスト。
            document.body.appendChild(にtextArea)。
            textArea.select(); 

            試す{
                 VAR成功= document.execCommand( 'コピー' )。
                
                警告(MSG)。 VARの MSG =成功'が正常にクリップボードにコピー':?「ブラウザは、「クリップボードにクリックコピーをサポートしていません。;「ブラウザは、クリップボードにコピー]をクリックしサポートしていません」); 
            } 
        }

 

おすすめ

転載: www.cnblogs.com/Angel-szl/p/11225300.html
おすすめ