Chuyển hướng tự động (auto redirect) là gì? Là việc khi người dùng xem một trang web thì được chuyển sang một trang web với url khác. Thủ thuật blogspot tự động auto random link cho blog, tự động chuyển hướng 1 link hoặc nhiều link cho blogspot, cách làm đơn giản với đoạn code JavaScript.
Mục đích Tự động chuyển hướng Blogspot để làm gì?
- Thay đổi địa chỉ trang web: Khi dùng trang web với tên miền mới và không sử dụng trang web cũ nhưng muốn người dùng truy cập trang cũ sẽ vào trang web mới.
- Bạn muốn một trang nào đó được redirect sang trang bạn muốn.
- Chuyển hướng Trang chủ sang trang Bài viết.
- Khi bạn không muốn sử dụng Blogspot nữa và chuyển sang một nền tảng mới.
Code tự động chuyển hướng bài viết có setup thời gian cho blogspot:
1. Chuyển hướng không có thời gian
<script type="text/javascript">window.location.href ="link"</script>
2. Chuyển hướng url blogspot có setup thời gian
<meta content="25;url=link" http-equiv="refresh"/>
3: Sử dụng thẻ META của HTML để chuyển hướng blogspot
<html><head><meta http-equiv="refresh" content="5;url=https://web7s.net/"></head><body>...</body></html>
Một số cách nâng cao để tự động chuyển hướng url blogspot
4: Sử dụng cơ chế Timeout của Javascript để chuyển hướng blogspot
<html><head><script type="text/javascript"><!--function delayer(){window.location = "http://www.new-url.com/"}//--></script></head><body onLoad="setTimeout('delayer()', 15000)"><h2>Prepare to be redirected after 15 second(s)!</h2></body></html>
<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE html><html b:version='2' class='v2' expr:dir='data:blog.languageDirection' xmlns='http://www.w3.org/1999/xhtml' xmlns:b='https://www.google.com/2005/gml/b' xmlns:data='https://www.google.com/2005/gml/data' xmlns:expr='https://www.google.com/2005/gml/expr'><head><script type="text/javascript">var time = 5; //How long (in seconds) to countdownvar page = "http://www.web7s.net"; //The page to redirect tofunction countDown(){time--;gett("container").innerHTML = time;if(time == -1){window.location = page;}}function gett(id){if(document.getElementById) return document.getElementById(id);if(document.all) return document.all.id;if(document.layers) return document.layers.id;if(window.opera) return window.opera.id;}function init(){if(gett('container')){setInterval(countDown, 1000);gett("container").innerHTML = time;}else{setTimeout(init, 50);}}document.onload = init();</script><meta content='IE=EmulateIE7' http-equiv='X-UA-Compatible'/><b:if cond='data:blog.isMobile'><meta content='width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0' name='viewport'/><b:else/><meta content='width=1100' name='viewport'/></b:if><b:include data='blog' name='all-head-content'/><title><data:blog.pageTitle/></title><b:skin><![CDATA[/*-----------------------------------------------/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////----------------------------------------------]]></b:skin></head><body><center><h1> Redirect minhquydesign.com </h1></center><h2>chuyển hướng sau <span id="container"></span> second(s)!</h2><!--S--><div style='margin-top:300px; '><center><p class='author'>© <b>Copyright by </b><a href='https://web7s.net/'> web7s net </a></p></center></div><b:section class='navbar' id='navbar' maxwidgets='1' showaddelement='no'/><!-- Credits intact--></body></html>
5. Tự động chuyển hướng đến bất kỳ 1 URL nào đó được cài sẵn (Auto Random Link)
Các bạn copy code dưới dán dưới thẻ mở <head>
<script type = 'text/javascript'>
//<![CDATA[
(function () {
setInterval(function () {
var redSites = [
"https://link1.blogspot.com",
"https://link2.blogspot.com",
"https://link3.blogspot.com",
"https://link4.blogspot.com",
"https://link5.blogspot.com"
];
var randomLinks = redSites[Math.floor(Math.random() * redSites.length)];
window.location = randomLinks
}, 2000)
}())
//]]>
</script>
Trong đó: 2000 tức là thời gian 2 giây sẽ tự động chuyển hướng random đến link bất kỳ nào đó bên trong.
Trên đây là 5 cách tự động chuyển hướng url bài viết có setup thời gian cho blogspot, hi vọng sẽ giúp ích gì đó cho các bạn. Chúc các bạn thành công!