1. مهمان گرامی، جهت ارسال پست، دانلود و سایر امکانات ویژه کاربران عضو، ثبت نام کنید.
    بستن اطلاعیه

یک اسکریپت برای سایتتان

شروع موضوع توسط ♥ yakamoz ♥ ‏4/12/10 در انجمن JS

  1. کاربر ویژه

    تاریخ عضویت:
    ‏25/11/10
    ارسال ها:
    8,717
    تشکر شده:
    4,395
    امتیاز دستاورد:
    123
    حرفه:
    Telegram: vahid_yakamoz instagram: vahid_yakamoz
    این اسکریپت مخصوس سایته
    سازگاری با تمام برنامه ها


    Description: This script records the date+time of your visitor's last visit and displays it upon their return. If this is their first visit to your site, a greeting message is shown instead. You can customize the messages to display in each case.

    Example: This is your 1st visit to our page

    (reload page to see time of your last visit)

    Directions

    Simply insert the below script where you wish to display the Last Visit message:



    <script type="text/javascript">

    /***********************************************
    * Display time of last visit script- by JavaScriptKit.com
    * This notice MUST stay intact for use
    * Visit JavaScript Kit at JavaScript Kit- Your comprehensive JavaScript, DHTML, CSS, and Ajax stop for this script and more
    ***********************************************/

    var lastvisit=new Object()
    lastvisit.firstvisitmsg="This is your first visit to this page. Welcome!" //Change first visit message here
    lastvisit.subsequentvisitmsg="Welcome back visitor! Your last visit was on <b>[displaydate]</b>" //Change subsequent visit message here

    lastvisit.getCookie=function(Name){ //get cookie value
    var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
    if (document.cookie.match(re)) //if cookie found
    return document.cookie.match(re)[0].split("=")[1] //return its value
    return ""
    }

    lastvisit.setCookie=function(name, value, days){ //set cookei value
    var expireDate = new Date()
    //set "expstring" to either future or past date, to set or delete cookie, respectively
    var expstring=expireDate.setDate(expireDate.getDate()+ parseInt(days))
    document.cookie = name+"="+value+"; expires="+expireDate.toGMTString()+"; path=/";
    }

    lastvisit.showmessage=function(){
    if (lastvisit.getCookie("visitcounter")==""){ //if first visit
    lastvisit.setCookie("visitcounter", 2, 730) //set "visitcounter" to 2 and for 730 days (2 years)
    document.write(lastvisit.firstvisitmsg)
    }
    else
    document.write(lastvisit.subsequentvisitmsg.replac e("\[displaydate\]", new Date().toLocaleString()))
    }

    lastvisit.showmessage()

    </script>