• Thống kê diễn đàn


[Code] zzRedirects v2 - Chuyển hướng liên kết ngoài

View previous topic View next topic Go down

[Code] zzRedirects v2 - Chuyển hướng liên kết ngoài Empty [Code] zzRedirects v2 - Chuyển hướng liên kết ngoài

Post by Bui Minh Phong™ 28/5/2014, 8:59 pm

[You must be registered and logged in to see this link.]

Là một Admin, đa phần đều muốn 4rum có lượng truy cập đông, thời gian ở lại lâu, tất nhiên sẽ chẳng ai muốn người xem rời đi chỉ vì click nhầm một liên kết nào đấy. Một thông báo, nhắc nhở khi người xem click vào liên kết lạ sẽ có ích trong trường hợp này, trong lúc người xem đang suy tư với thì một số Admin còn gắn thêm quảng cáo, hoặc kèm vài lời đe dọa như: Chúng tôi không chịu trách nhiệm khi bạn chuyển đến liên kết này, bala bala...

Demo: [You must be registered and logged in to see this link.]

[Code] zzRedirects v2 - Chuyển hướng liên kết ngoài 4p9Tok2

Chức năng:


  • Khi người xem click vào liên kết ngoài (trừ liên kết ảnh), sẽ xuất hiện một thông báo chuyển hướng với 2 lựa chọn: Trở về hoặc tiếp tục.
  • Tự chuyển trang sau 5 giây nếu người dùng không lựa chọn.
  • Thông báo lỗi nếu sai thông số chuyển hướng



Hướng dẫn:


Bước 1: CSS
ACP >> Display >> Pictures and Colors >> Colors >> CSS Stylesheet

Code:
/* zzRedirects v2 - devs.forumvi.com */
#redirects{width:75%;margin:30px auto;padding:20px 30px;border:1px solid #DDD}
#redirects h3{border-bottom:1px solid #ddd;font-size:17px;font-weight:400;padding-bottom:10px;color:#830000;margin:0 0 20px}
#redirects p{color:#222;font-size:13px;line-height:20px;margin:5px auto 15px}
.redirectFooter{background-color:#fff;padding:20px 0 30px}
#redirectButtons{float:right;list-style-type:none;margin:0;padding:0}
#redirectButtons li{float:left}
#redirectButtons a{transition:all .2s linear 0;-moz-transition:all .2s linear 0;-o-transition:all .2s linear 0;-webkit-transition:all .2s linear 0;background-color:#0063dc;border:0 none;color:#fff!important;font-size:12px;line-height:30px;min-width:45px;text-align:center;display:block;text-decoration:none!important;padding:0 10px}
#redirectButtons a.cancel{background-color:#eee;color:#888!important;margin-right:10px}
#redirectButtons a:hover{background:#333}


Bước 2: Javascript:
ACP >> Modules >> HTML & JAVASCRIPT >> Javascript codes management >> Create a new javascript

Title * : zzRedirect
Placement : In the topics
Javascript Code * :
Code:
/* zzRedirects v2 - devs.forumvi.com */
$(function () {
    $(".post-entry a").not("a[href$='.jpg'],a[href$='.jpeg'],a[href$='.png'],a[href$='.gif'],a[href$='.bmp'],a[href^='/'],a[href^='#'],a[href^='?'],a[href^='http://" + location.host + "']").addClass("external").click(function (a) {
        a.preventDefault();
        window.open("/h13-redirect?from=" + location.href.replace(/.+(t\d+(p\d+)?)-.+/, "$1") + "-" + $(this).closest(".post").children("a:first").attr("name") + "&to=" + encodeURIComponent(this.href), document.title);
    });
});


Bước 3: HTML:
ACP >> Modules >> HTML & JAVASCRIPT >> HTML pages management >> Create in advanced mode (HTML)

Do you wish to use your forum header and footer ?: Có
Page content *
Code:
<script type="text/javascript">
//<![CDATA[
/* zzRedirects v2 - devs.forumvi.com */
(function () {
    $("#main-content").html('<div id="redirects"><h3><span id="reTitle">Lỗi</span> chuyển hướng...</h3><p id="redirectMess"><span style="color:red">Không tìm thấy tham số cần thiết.</span><br />Đây là trang xác nhận chuyển hướng đến các liên kết ngoài diễn đàn. Nếu bạn vô tình vào trang này, hãy nhấn vào <a href="/" rel="nofollow" style="font-weight: bold; color: blue;">đây</a> để quay lại. Nếu không, hãy <a href="/contact" rel="nofollow" style="font-weight: bold; color: green;">liên hệ</a> với BQT để báo lỗi này.</p><div class="redirectFooter"><ul id="redirectButtons"><li><a id="fromLink" class="cancel" href="">Quay lại</a></li></ul></div></div>');
    var a = GetParam("from"),
        b = GetParam("to"),
        d = "/";
    if (null !== a && null !== b) {
        b = decodeURIComponent(b);
        a = a.split("-");
        d = "/" + a[0] + "-topic#" + a[1];
        $("#reTitle").text("Đang");
        $("#redirectMess").html('Bạn đang chuẩn bị rời khỏi <span id="fromTitle">diễn đàn</span> và di chuyển đến đường dẫn: <b><a id="toLink" href="" title="" rel="nofollow">...</a></b> trong vòng <b><span class="delayTime">5</span></b> giây nữa...<br />Bạn có chắc chắn là muốn đến đường dẫn này không?');
        (a = window.name) && $("#fromTitle").html("<strong>" + a + "</strong>");
        window.name = "";
        a = b;
        35 <= b.length && (a = b.slice(0, 32) + "...");
        $("#toLink").attr({
            href: b,
            title: b
        }).text(a);
        $("#redirectButtons").append('<li><a href="' + b + '" id="gotoBtn" class="redirectSkip forward" rel="nofollow">Tiếp tục (<span class="delayTime">5</span>)</a></li>');
        var c, e = 5;
        c = setInterval(function () {
            var a = e--;
            0 > a ? (clearInterval(c), window.location = b) : $(".delayTime").text(a)
        }, 1E3);
        $("a", "#redirectButtons").click(function () {
            clearInterval(c)
        })
    }
    $("#fromLink").attr("href", d)
})();
//]]>
</script>


Zzbaivong
Bui Minh Phong™
Bui Minh Phong™
Quản Trị Cấp Cao
Quản Trị Cấp Cao

Posts : 3260
Points : 370912
Thanked : 1927
Birthday : 1994-12-18
Status Hãy Lặng Yên Để Cảm Nhận Tình Yêu Xung Quanh Bạn :x
Giới tính : Male Rất dễ thương

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum