Lê Ngọc Cường - Peajastr

Tạo mật khẩu bài viết cho blogspot

Đặt pass cho  toàn bộ các trang trên blog tức là khi vào trang chủ hay các trang bài viết bạn cũng phải nhập password mới có thể xem được. 

Chèn code bên dưới vào sau thẻ <head>

<script language='JavaScript'>
var password;
var pass1="cuongle";
password=prompt('Please enter your password to view this page!','');
if (password==pass1)
alert('Password Correct! Click OK to enter!');
else
{
window.location="http://www.tensite.com";
}
</script>

Thay dòng cuongle thành password, dòng http://www.tensite.com là địa chỉ được trả về khi bạn đánh sai password hay nhấn cancel. Save template lại là xong.

Đặt password cho một bài viết nhất định

Chèn code bên dưới vào sau thẻ <head>

<b:if cond='data:blog.url == "http://www.traidatmui.com/2010/11/hien-thi-bai-viet-voi-hieu-ung-truot.html"'>
<script language='JavaScript'>
var password;
var pass1="cuongle";
password=prompt('Please enter your password to view this page!','');
if (password==pass1)
alert(';Password Correct! Click OK to enter!');
else
{
window.location="http://www.tensite.com/2010/11/hien-thi-bai-viet-voi-hieu-ung-truot.html";
}
</script>
</b:if>

Thay dòng cuongle thành password, dòngvà địa chỉ được trả về khi bạn đánh sai password hay nhấn cancel. Save template lại là xong.

Đặt password cho các bài viết trên blog

<b:if cond='data:blog.pageType == "item"'>
<script language='JavaScript'>
var password;
var pass1="cuongle";
password=prompt('Please enter your password to view this page!','');
if (password==pass1)
alert('Password Correct! Click OK to enter!');
else
{
window.location="http://www.tensite.com/2010/11/hien-thi-bai-viet-voi-hieu-ung-truot.html";
}
</script>
</b:if>

Bạn cũng có thể thiết lập nhiều password cho trang đó, chỉ cần nhập đúng 1 trong các password được thiết lập sẵn trước đó bạn sẽ vào được trang đó. Và code có dạng như bên dưới.

<script language='JavaScript'>
var password;
var pass1="pass1";
var pass2="pass2";
password=prompt('Please enter your password to view this page!','');
if (password==pass1 || password==pass2)
alert('Password Correct! Click OK to enter!');
else
{
window.location="http://www.cuongle.com";
}
</script>

LƯU Ý: Thường thì người dùng sẽ không biết mật khẩu để truy cập được, nhưng có một nhược điểm là nếu một coder nào nhấn Ctrl + U để soi code thì sẽ biết mật khẩu của bạn là gi? vì vậy mình có một giải pháp là mã hóa đoạn code JS đó rồi dán nhé!
Xem thêm: Mã hóa code JS chèn vào blogspot

Không có nhận xét nào:

AjMrDeSiGn