- 정보공유
[기타] 텍스트 복사
function copyToClipboard(elementId) {
var aux = document.createElement("input");
aux.setAttribute("value", document.getElementById(elementId).innerHTML);
document.body.appendChild(aux);
aux.select();
document.execCommand("copy");
document.body.removeChild(aux);
alert("복사되었습니다.");
}
<p class="hidden" id="copy_url"><?php echo "https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; ?></p>
<button type="button" onclick="copyToClipboard('copy_url')" class="btn btn-default"><i class="fti link_copy"></i><span class="ft11 text-black ml-5">링크 복사하기</span></button>