Xử lý external link cho website

Đây là đoạn jQuery để xử lý exteral link cho website… script sẽ tìm từng thẻ a trên web, nếu là external link thì sẽ cập nhật 2 attribute là ref=’nofollow’ và target =’_blank’…

<script>
$(document).ready(function(){
    $("a").each(function() {
        if (this.hostname !== location.hostname) {
            $(this).attr("rel", "nofollow");
            $(this).attr("target", "_blank");
        }
    });
});
</script>

Ngoài ra, nếu dùng wordpress thì có thể tham khảo qua plug-in: SyntaxHighlighter Evolved, hoặc Crayon Syntax Highlighter

RELATED POSTS
Share the Post: