JS實現 分享視訊中-->點選button(copy),複製對應網址
分享視訊中-->點選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按鈕