DTE :]

Wednesday, January 18, 2012

Auto Updated Copyright Year

Tampilkan tahun awal website dibuat sampai saat ini secara otomatis:

Copyright &copy; 2012 - <span id='current-year'></span>
     
<script>
    function getCurrentYear() {
        var d = new Date();
        return d.getFullYear();
    }
    el = document.getElementById('current-year');
    el.innerHTML = getCurrentYear();
</script>

Sumber: http://snipplr.com/view/46444/

Labels: ,

2 Comments:

  • bang taufic kalau untuk memasukkan stylesheet (css) external kedalam html kok gax bisa yah ?
    mungkin ada di Jquery atau bsa di javascript
    ini script saya bg

    var d = new Date();
    var weekday = new Array(7);
    weekday[0] = "minggu";
    weekday[1] = "senin";
    weekday[2] = "selasa";
    weekday[3] = "rabu";
    weekday[4] = "kamis";
    weekday[5] = "jum'at";
    weekday[6] = "sabtu";
    var b = weekday[d.getDay()];
    document.write("< link type='text/css' rel='stylesheet' href='http://blogspot-edi.googlecode.com/files/" + b + ".css' >");

    By Blogger Bakteri, at Tuesday, July 17, 2012 at 8:47:00 PM GMT+7  

  • Belum dites, tapi mungkin ini bisa dipakai:

    function switchStyle() {
    var d = new Date();
    var weekday = [];
    weekday[0] = "minggu";
    weekday[1] = "senin";
    weekday[2] = "selasa";
    weekday[3] = "rabu";
    weekday[4] = "kamis";
    weekday[5] = "jum'at";
    weekday[6] = "sabtu";
    var b = weekday[d.getDay()];
    var css = document.createElement('link');
    css.rel = "stylesheet";
    css.type = "text/css";
    css.href = "http://blogspot-edi.googlecode.com/files/" + b + ".css";
    css.media = "screen";
    document.getElementsByTagName('head')[0].appendChild(css);
    } switchStyle();


    Kalau tidak bekerja, mungkin kode CSS-nya yang tidak bisa dibaca. Coba unggah di direktori Google Pages, Pastebin atau Dropbox dibandingkan Google Code.

    By Blogger Taufik Nurrohman, at Tuesday, July 17, 2012 at 9:43:00 PM GMT+7  

Post a Comment



<< Home