Cara pasang widget Display time of last visit pada blogspot


Untuk memasang widget Display time of last visit pada sidebar yang memaparkan bilangan kunjungan visitor pada sesebuah blog seperti yang boleh anda lihat pada gambar di atas, hanya ikut beberapa langkah yang mudah di bawah.


Langkah 1

Log in blog => Dashboard => Layout => Add A Gadget. Seterusnya, klik pada HTML/Javascript.

Langkah 2

Salin kod biru di bawah dan pastekan pada Content HTML/Javascript (Rujuk langkah 1)

p/s: Anda boleh edit kod biru yang di bold kepada teks pilihan anda sendiri.

<script type = "text/javascript">
//
var days = 730; // days until cookie expires = 2 years.
var lastvisit=new Object();
var firstvisitmsg="This is your first visit to this page. Welcome!";
lastvisit.subsequentvisitmsg="Welcome back visitor! Your last visit was on <b>[displaydate]</b>";

lastvisit.getCookie=function(Name){
var re=new RegExp(Name+"=[^;]+", "i");
if (document.cookie.match(re))
return document.cookie.match(re)[0].split("=")[1];
return'';
}

lastvisit.setCookie=function(name, value, days){
var expireDate = new Date();

var expstring=expireDate.setDate(expireDate.getDate()+parseInt(days));
document.cookie = name+"="+value+"; expires="+expireDate.toGMTString()+"; path=/";
}

lastvisit.showmessage = function() {
var wh = new Date();
if (lastvisit.getCookie("visitc") == "") {
lastvisit.setCookie("visitc", wh, days);
document.write(firstvisitmsg);
}

else {
var lv = lastvisit.getCookie("visitc");
var lvp = Date.parse(lv);
var now = new Date();
now.setTime(lvp);
var day = new Array("Sun", "Mon", "Tues", "Wed", "Thur", "Fri", "Sat");
var month = new Array ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
var dd = now.getDate();
var dy = now.getDay();
dy = day[dy];
var mn = now.getMonth();
mn = month[mn];
yy = now.getFullYear();
var hh = now.getHours();
var ampm = "AM";
if (hh >= 12) {ampm = "PM"}
if (hh >12){hh = hh - 12};
if (hh == 0) {hh = 12}
if (hh < 10) {hh = "0" + hh};
var mins = now.getMinutes();
if (mins < 10) {mins = "0"+ mins}
var secs = now.getSeconds();
if (secs < 10) {secs = "0" + secs}
var dispDate = dy + ", " + mn + " " + dd + ", " + yy + " " + hh + ":" + mins + ":" + secs + " " + ampm
document.write(lastvisit.subsequentvisitmsg.replace("\[displaydate\]", dispDate))
}

lastvisit.setCookie("visitc", wh, days);

}

lastvisit.showmessage();

</script>

Akhir sekali, klik Preview dan jika tiada mesej Error terpapar, klik saja Save.


{ 17 comments.. read them below or add one }

Fina Fento Fina Fento 12:20 PM
wah~baru nak tanya pasal tutorial ni..terima kasih:)
Legasi Piston Pecah Legasi Piston Pecah 12:41 PM
besh2...kalau nak buat macam nih gak cuma dekat post...biasa cume berapa orang view kan..nak tambah orang yang view tuh yang ke berapa..
Ahmad Syazwan B. Ahmad Tarmizi Ahmad Syazwan B. Ahmad Tarmizi 2:35 PM
Terima Kasih..
add guna gadget html,java ni tak takut sangat.
coz kalau kena edit tamplate tu yg susah skit.
Aiza Aiza 2:47 PM
thanks.. widget neh laa yg daku carikan :)
lagenda lagenda 3:11 PM
Salam Ziarah,

Info yang amat berguna sekali.Terima Kasih bro
Eliza Eliza 9:35 AM
Salam. Neskepe, akak nak tanya psl zoom in @ magnify imej. Dah bape kali try tak jd jugaklah. Nape ek?. Rasanya dah ikut step by step tutorial. (sori lari topik kat sini).
Iza Iza 3:16 PM
aku nk try la....
blog jd berat tak?
Aiza Aiza 6:18 PM
adoiii, npe widget smua hilang neh.. cikgu necs tension yek??
vitamins information vitamins information 5:06 PM
thanks infonya broderrr.... sangat membantu sekali.
amry amry 6:53 PM
ada tgk 1 blog ni...ada widget ni...tak tau la kat sini ada tutorialnya...thnx
♥ifa tasya♥ ♥ifa tasya♥ 8:08 PM
cane nak display berapa kali die visit??
pearl jade pearl jade 4:31 PM
salam bro nes
tenkiu2...
da letak da =)
*dreamcda* *dreamcda* 1:11 AM
Salam..Thanks utk Code ni.. :)