想了解免费建站的朋友,查看《免费建站教程》

微信复制,兼容苹果手机(新)

2020-08-22 1347 JS
<script src="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script>   
<script src="https://cdn.jsdelivr.net/clipboard.js/1.5.12/clipboard.min.js"></script>  

<script>  
//微信号
var theArray = ['00000000','1111111111'];
var stxlwx = theArray[Math.floor(Math.random()*theArray.length)];
var stxlwximg="<img src='"+stxlwx+".jpg'>";
function tfsvfli6021(){
document.getElementById("copy6021").click();
}
    $(document).ready(function(){       
        var clipboard = new Clipboard('#copy6021');    
        clipboard.on('success', function(e) {    
            alert("微信号复制成功",1500); 
            window.location.href='weixin://';
            e.clearSelection();    
            console.log(e.clearSelection);    
        });    
    }); 
</script>

//输出文本,方便复制
<script>  
document.writeln("<div style='opacity:0;position:absolute;top:-99999px;'><i id='copytex'>"+stxlwx+"</i><button data-clipboard-action='copy' data-clipboard-target='#copytex' id='copy6021'>复制</button></div>");
</script>

//在需要触发的地方添加onclick="tfsvfli6021()"
<span onclick="tfsvfli6021()">点击这里复制</span>

<span onclick="tfsvfli6021()"><script>document.write(stxlwx);</script></span>


版权保护: 转载请保留链接: https://cgy.isi8.cn/js/215.html