JS实现 分享视频中-->点击button(copy),复制对应网址

来源:互联网 发布:襄阳樊城区移动云计算 编辑:程序博客网 时间:2024/05/19 13:45

分享视频中-->点击button(copy),复制对应网址


HTML页面代码

<input type="text" class="share-input" value="http://www.youtube.com" id="copy-content"/>
<button class="copy-button" type="button" onclick="copyContent();"> Copy </button>
<p> Embed </p>
<input type="text" class="share-input" value="http://www.vimeo.com" id="copy-embed"/>
<button class="copy-button" type="button" onclick="copyEmbed();"> Copy </button>


JS代码

    /*Copy function implementation */
    function copyContent(){ 
        var copyobject=document.getElementById("copy-content");
        copyobject.select();
        document.execCommand("Copy");
        alert("has been copied you can paste"); 
    };
    
    function copyEmbed(){ 
        var copyobject=document.getElementById("copy-embed");
        copyobject.select(); 
        document.execCommand("Copy"); 
        alert("has been copied you can paste"); 
    };


效果图

页面效果图


点击Copy按钮


0 0
原创粉丝点击