<div id="urlDiv"><button type="button" style="cursor:pointer" onclick="urlCopy()">주소복사</button></div>
<script>
function urlCopy() {
urlDivHtml = urlDiv.innerHTML;
urlDiv.innerHTML = urlDivHtml + "<textarea>" + location.href + "</textarea>";
urlDiv.querySelector("textarea").select();
document.execCommand("copy");
urlDiv.innerHTML = urlDivHtml;
alert("주소가 복사되었습니다");
}
</script>