url 주소 복사

1545 단어
전방 인터넷에서 본 좋은 코드 예는 여기에 기록으로 쓴다



function copyUrl2()
{
var Url2=document.getElementById("biao1");
Url2.select(); //     
document.execCommand("Copy"); //          
alert("    ,   。");
}


그러나 이 코드는 휴대전화 측을 잘 호환할 수 없기 때문에 저자는 다음과 같이 코드를 개선했다.
$(document).on('click', '.link', function() {
            var url = window.location.href;
                Url2 = document.getElementById("url");
            $('#url').val(url);
            $('#url1').text(url);
            if( document.execCommand('Copy') ) {
                Url2.select(); //     
                document.execCommand("Copy"); //          
                $.customTips({
                    msg : '    '
                });
                $('.share-main').removeClass('show');
                setTimeout(function() {
                    $('.share-box').hide();
                },100);
            } else {
                $('.share-main').removeClass('show');
                $('.link-main').show();
            }
        });

루트 글꼴 크기를 조정하려면:
(function() {
    //        
    var winWidth = document.body.clientWidth;
    document.querySelector('html').style.fontSize = winWidth/640 * 24 + 'px';
})()

좋은 웹페이지 즐겨찾기