Dưới đây mình xin chia sẽ mã nguồn tự động chuyển hướng trang web mỗi khi lick chuột vào (code random link) được viết dước dạng javascript. Mình làm mặc định là 10 link, khi bạn copy về dùng thì có thể thêm hoặt bớt các link theo mong muốn của bạn. Các chữ URL1 đến URL10 các bạn hãy đổi thành đường link mà bạn muốn tự động chuyển đến đó.
<script type="text/javascript">
var urls = new Array();
urls[0] = "URL1";
urls[1] = "URL2";
urls[2] = "URL3";
urls[4] = "URL4";
urls[5] = "URL5";
urls[6] = "URL6";
urls[7] = "URL7";
urls[8] = "URL8";
urls[9] = "URL9";
urls[10] = "URL10";
var random = Math.floor(Math.random()*urls.length);
window.location = urls[random];
</script>
Còn dưới đây là 1 code random bài viết, mỗi khi khác truy cập chúng sẽ trả về một đường link ngẫu nhiên.
<script type="text/javascript">
link = new Array(
'<div class="list1"><font color="red">» </font><a href="https://sites.google.com/site/utnhanphan/home/buddha/42-thu-nhan-an-phap-theo-chu-dai-bi-1">42 Thủ Nhãn ấn pháp theo chú Đại Bi</a></div>',
'<div class="list1"><font color="red">» </font><a href="https://sites.google.com/site/utnhanphan/home/buddha/84-hinh-anh-minh-hoa-chu-dai-bi">84 hình ảnh minh họa Chú Đại Bi</a></div>',
'<div class="list1"><font color="red">» </font><a href="https://sites.google.com/site/utnhanphan/home/buddha/hoa-hao-buddhism/sam-giang-giao-ly/su-cung-lay-cua-nguoi-cu-si-tai-gia">Sự cúng lạy của người cư-sĩ tại gia</a></div>',
'<div class="list1"><font color="red">» </font><a href="https://sites.google.com/site/utnhanphan/home/buddha/hoa-hao-buddhism/thi-van-giao-ly/33-toa-thuoc-gia-truyen-ma-duc-thay-da-giao-cho-anh-em-tin-do-o-bac-lieu-hoi-thang-6-dl-1945">33 toa thuốc gia truyền của Đức thầy</a></div>',
'<div class="list1"><font color="red">» </font><a href="https://sites.google.com/site/utnhanphan/home/buddha/book/15-thu-khong-the-mua-duoc-bang-tien">15 thứ không thể mua được bằng tiền</a></div>',
'<div class="list1"><font color="red">» </font><a href="https://sites.google.com/site/utnhanphan/home/buddha/book/66-loi-phat-day-ve-cuoc-song">66 lời Phật dạy về cuộc sống</a></div>'
);
n=Math.floor(Math.random() * 6);
document.write(link[n]);
</script>