Hướng dẫn tạo trang ẩn link hoặc trang chuyển link cho blog
Sau đó tìm đến thẻ </body>
Đoạn code này sẽ khắc phục được lỗi nảy tab mới. Chúc các bạn thành công
Để tạo trang ẩn link ta cần làm theo hướng dẫn sau:
Bước 1: Tạo trang mới trong blog và nhập nội dung bên dưới vào và ấn xuât bản.
Lưu ý: Thay link bôi vàng bằng link blog của bạn
//Nếu muốn encode/decode bằng base64 để ẩn link thì thay thế hàm decodeURIComponent thành btoa
<div class="separator" style="clear: both;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi60QOr9dBe57oi1P8p4mnhgMEECSlVYCGDCUVv88XSLmAhkDYKjRqEPSXHpkkzQf4kd_NBUOsSmukgqDFFpRuYtnyalVnwxOzqNY4myPGRtzo7B7-395_xDYj91uKk8JvD3idBF7LSTLQ/s1569/logo1.jpg" style="display: block; padding: 1em 0; text-align: center; "><img alt="" border="0" width="400" data-original-height="1569" data-original-width="1569" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi60QOr9dBe57oi1P8p4mnhgMEECSlVYCGDCUVv88XSLmAhkDYKjRqEPSXHpkkzQf4kd_NBUOsSmukgqDFFpRuYtnyalVnwxOzqNY4myPGRtzo7B7-395_xDYj91uKk8JvD3idBF7LSTLQ/s400/logo1.jpg"/></a></div><center><a class="btn btn-success btn-lg disabled" href="https://www.letuan.edu.vn/" id="redirect-btn" rel="noreferrer noopener" target="_blank" disabled>Click here to continue!</a><script>((document) => {let h = document.location.hash,$btn = document.querySelector('#redirect-btn');if (h.length > 0 && h.startsWith('#http')) {try {let url = new URL(decodeURIComponent(h.substr(1)));url.searchParams.set('utm_source', 'letuan.edu.vn');$btn.href = url.href;} catch (e) {console.error(e.message);return;}}let i = 10,txt = $btn.textContent;function run() {$btn.textContent = `${txt} (${i})`;if (i > 0) {i--;setTimeout(run, 1000);} else {$btn.textContent = txt;$btn.removeAttribute('disabled');$btn.classList.remove('disabled');}}run();})(document);</script><link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/css/bootstrap.min.css" rel="stylesheet"></link></center>
Bước 2: Thêm đoạn code sau vào trước thẻ </body>
Vào Chủ đề -> Chỉnh sửa HTML
Sau đó tìm đến thẻ </body>
Lưu ý: Thay các phần bôi vàng bằng link của trang đã tạo ở bước 1
<!-- Chuyen huong trang -->
<script>//<![CDATA[/* Redirector */
(function(b){window.top.location.href.includes("/p/vip-link.html")||b.filter(function(a){return!a.hasAttribute("imageanchor")&&!a.href.startsWith("https://www.letuan.edu.vn/")&&5<a.href.length}).map(function(a){a.href="https://www.letuan.edu.vn/p/vip-link.html#"+encodeURIComponent(a.href);a.target="_blank";a.rel="nofollow noopener"})})(Array.from(document.querySelectorAll(".post-body a")));//]]></script>
<!-- Chuyen huong trang -->
Cách khắc phục lỗi khi chèn Table of Content bị nhảy tab mới
Nếu bạn dùng Table of Content mà bị lỗi khi bấm vào nhảy tab mới thì nguyên nhân là do javascript chỉ biến đổi link nếu bắt đầu bằng tên miền bạn quy định (trong blog mình là letuan.edu.vn) vì vậy các thẻ <a> mà không có href là letuan.edu.vn thì nó sẽ đổi link.Vì vậy mình đã sửa lại đoạn code thành:
<script>//<![CDATA[/* Redirector */(function(b){window.top.location.href.includes("/p/vip-link.html")||b.filter(function(a){return!a.hasAttribute("imageanchor")&&!a.href.startsWith("https://www.letuan.edu.vn/")&&!a.href.startsWith("javascript:")&&5<a.href.length}).map(function(a){a.href="https://www.letuan.edu.vn/p/vip-link.html#"+encodeURIComponent(a.href);a.target="_blank";a.rel="nofollow noopener"})})(Array.from(document.querySelectorAll(".post-body a")));//]]></script>
Hướng dẫn encode base64 cho url
Thay hàm encodeURIComponent = atob
Và decodeURIComponent = btoa