Show Mobile Navigation

Add a Display Time of Last Visit Widget

Hemant Verma - 8:09 PM

As we all want to track our visitors on our site but suppose if visitor want to know that last time when she/he open this site and what's the time OR day so that would be interesting for the visitor and also it will a very unique content OR widget for blog owner, so you can easily add a widget like this where your visitors can track them that when they last time visit this site.

This widget is simply made by the JavaScript and HTML.



widgetgenerators.blogspot.com




Add Display Time of Last Visit Widget

  • Login to Blogger > Dashboard
  • Click on Drop Down Menu and select Layout
  • Click on Add a Gadget and Choose HTML/JavaScript Widget
  • Paste below code in it. 

<script type = "text/javascript">

/***********************************************
* Display time of last visit script- by http://widgetgenerators.blogspot.com

* This notice MUST stay intact for use
* Visit JavaScript Kit at
http://widgetgenerators.blogspot.com for this script and more blogging stuff is  waiting for u.
***********************************************/

var days = 730; // days until cookie expires = 2 years.
var lastvisit=new Object();
var firstvisitmsg="This is Your First Visit on This Website. 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>

  • Now Click on Save Button.


Note:- Add Your HTML/JavaScript Widget on below position (see image)




Make Changes (Optional)

  • You can replace this text This is Your First Visit on This Website. Welcome! with your own text (Optional)
  • You can also replace this text Welcome Back Visitor! Your Last Visit Was on with your own text (Optional)


Give Your Feedback About This Widget


2 comments:

  1. good widget nd very helpful for visitors but it looks simple and small fonts. fonts should be large.

    mind it plz otherwise widget is very good

    ReplyDelete
  2. @Vicky Saxena

    ya I already try to change the font size and make it stylish but not able to do it. be'coz it's related with javascript but i'll try to make it possible and i'll post it's updated version. ASAP

    Thanks for your suggestion.
    Stay with Us

    ReplyDelete

You may use these HTML tags and attributes: <a href="" title=""> </a> <b> </b><strong> </strong>

 



Make Your Blog Like a Pro
About | Contact | Affiliates | Privacy Policy | TOS