friendsterTalk - Friendster Forum

friendsterTalk - Friendster Forum

Welcome guest! Please Login or Register.

#1  2009-01-03 15:20:22

aidenlive
aidenlive's display avatar
» FriendsterWhiz
Registered: 2007-06-16
Posts: 3265
Reputation: 11

Custom Cursor Script II (CrossHair Mouse Cursor)

Description: This script adds a custom cursor to your webpage using an interchangeable image. The result is a custom mouse cursor that can be modified in anyway your graphic skills take you. Elegant and non intrusive effect!

Script tested in IE6+, Firefox 1.x+, and Opera 8+.

PREVIEW

Step 1: Download one of the below images to be used as your custom cursor image
(or create your own!):


js code:

var skinableCursor = {


   
    skinPath : 'IMAGE OF CURSOR',


   
    IE : ( document.all && document.getElementById && !window.opera ),
    FF : (!document.all && document.getElementById && !window.opera),
    OP : (document.all && document.getElementById && window.opera),


   
    cursor : {
        lt : { x : '0px',    y : '0px',    w : '19px',    h : '26px' ,    dx : -22,    dy : -22 },
        rt : { x : '19px',    y : '0px',    w : '26px',    h : '19px' ,    dx : -3,    dy : -22 },
        rb : { x : '26px',    y : '19px',    w : '19px',    h : '26px' ,    dx : 4,        dy : -3 },
        lb : { x : '0px',    y : '26px',    w : '26px',    h : '19px' ,    dx : -22,    dy : 4 }
    },


   
    init : function () {

        skinableCursor.cursor.browserDelta = (skinableCursor.IE ? 2 : 0);

        if ( skinableCursor.FF || skinableCursor.OP ) {
            document.addEventListener("DOMContentLoaded", skinableCursor.domReady, false);
        }

        if ( skinableCursor.IE ) {

            document.write("<scr" + "ipt id=__ieinit defer=true " +
                "src=//:><\/script>");

            var script = document.getElementById("__ieinit");
            script.onreadystatechange = function() {
                if ( this.readyState != "complete" ) return;
                this.parentNode.removeChild( this );
                skinableCursor.domReady();
            };

            script = null;
        }
    },


   
    domReady : function () {

        skinableCursor.create();

        if ( skinableCursor.FF || skinableCursor.OP ) {
            var s = document.createElement('style');
            s.innerHTML = '* { cursor: inherit; } html { height: 100%; } body, html { cursor: crosshair; }';
            document.body.appendChild(s);
            document.addEventListener('mousemove', skinableCursor.move, false);
        }

        if ( skinableCursor.IE ) {
            var s = document.createStyleSheet()
            s.addRule("*", "cursor: inherit");
            s.addRule("body", "cursor: crosshair");
            s.addRule("html", "cursor: crosshair");
            document.attachEvent('onmousemove', skinableCursor.move);
        }

        var anchors = document.getElementsByTagName('a');
        for (x = 0; x < anchors.length; x++) {
            if ( skinableCursor.FF || skinableCursor.OP ) {
                anchors[x].addEventListener('mousemove', skinableCursor.events.anchor, false);
                anchors[x].addEventListener('mouseout', skinableCursor.events.show, false);
            }

            if ( skinableCursor.IE ) {
                anchors[x].attachEvent('onmousemove', skinableCursor.events.anchor);
                anchors[x].attachEvent('onmouseout', skinableCursor.events.show);
            }
        }

    },


   
    create : function () {

        function create(el, d) {
            el.style.position = 'absolute';
            el.style.overflow = 'hidden';
            el.style.display = 'none';
            el.style.left = d.x;
            el.style.top = d.y;
            el.style.width = d.w;
            el.style.height = d.h;
            if ( skinableCursor.IE ) {
                el.innerHTML = '<img src="' + skinableCursor.skinPath + '" style="margin: -' + d.y + ' 0px 0px -' + d.x + '">';
            } else {
                el.style.background = 'url(' + skinableCursor.skinPath + ') -' + d.x + ' -' + d.y;
            }
            return el;
        }

        var c = skinableCursor.cursor;
        c.lt.el = create(document.createElement('div'), c.lt);
        c.rt.el = create(document.createElement('div'), c.rt);
        c.rb.el = create(document.createElement('div'), c.rb);
        c.lb.el = create(document.createElement('div'), c.lb);

        document.body.appendChild(c.lt.el);
        document.body.appendChild(c.rt.el);
        document.body.appendChild(c.rb.el);
        document.body.appendChild(c.lb.el);

    },


   
    move : function (e) {

        function pos(el, x, y) {
            el.el.style.left = x + el.dx + 'px';
            el.el.style.top = y + el.dy + 'px';
        }

        function hide(el, x, y) {
            var w = document.documentElement.clientWidth;
            var h = document.documentElement.clientHeight;
            var deltaX = w - (x + el.dx + parseInt(el.w) - skinableCursor.cursor.browserDelta);
            var deltaY = h - (y + el.dy + parseInt(el.h) - skinableCursor.cursor.browserDelta);
            if (!skinableCursor.noSkin) {
                el.el.style.display = deltaX > 0 ? (deltaY > 0 ? 'block' : 'none') : 'none';
            }
        }

        var p = skinableCursor.getMousePosition(e);
        var s = skinableCursor.getScrollPosition();
        var c = skinableCursor.cursor;
        var x = p.x + s.x - c.browserDelta;
        var y = p.y + s.y - c.browserDelta;

        hide(c.lt, p.x, p.y);
        hide(c.rt, p.x, p.y);
        hide(c.rb, p.x, p.y);
        hide(c.lb, p.x, p.y);

        pos(c.lt, x, y);
        pos(c.rt, x, y);
        pos(c.rb, x, y);
        pos(c.lb, x, y);

    },


   
    getMousePosition : function (e) {

        e = e ? e : window.event;
        var position = {
            'x' : e.clientX,
            'y' : e.clientY
        }

        return position;

    },


   
    getScrollPosition : function () {

        var x = 0;
        var y = 0;

        if( typeof( window.pageYOffset ) == 'number' ) {
            x = window.pageXOffset;
            y = window.pageYOffset;
        } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
            x = document.documentElement.scrollLeft;
            y = document.documentElement.scrollTop;
        } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
            x = document.body.scrollLeft;
            y = document.body.scrollTop;
        }

        var position = {
            'x' : x,
            'y' : y
        }

        return position;

    },


   
    events : {

        anchor : function (e) {
            skinableCursor.noSkin = true;
            document.body.style.cursor = 'pointer';

            var c = skinableCursor.cursor;
            c.lt.el.style.display = 'none';
            c.rt.el.style.display = 'none';
            c.rb.el.style.display = 'none';
            c.lb.el.style.display = 'none';

        },

        show : function () {
            skinableCursor.noSkin = false;
            document.body.style.cursor = 'crosshair';
        }

    }

}

skinableCursor.init();

Credits: Webtoolkit.info

Last edited by aidenlive (2009-01-04 02:05:43)

#2  2009-01-04 00:04:02

akoba
akoba's display avatar
» FriendsterManiac
Barkada Trip
Registered: 2008-08-23
Posts: 778
Last visit: Today
Reputation: 23

Re: Custom Cursor Script II (CrossHair Mouse Cursor)

coockie wrote:

ahhh. ikaw ba ang aiden?
ahh.. ako pala ung nag report nang tatlong accounts mo sa friendster kaya ka suspended.:D

what's your point? ***offtopic ***

anyway thnx for sharing this will be handy



iPhone 3G : Activated/Jailbroken/Unlock (yellowsn0w) it works
iPhone 2G : Activated/Jailbroken/Unlock

All credit goes to where it due.  :)
Thanks to all who give me a + repu.

#3  2009-01-04 04:31:48

slashedkite
 I got amnesia.
slashedkite's display avatar
» FriendsterGeek
GRANDCHASER
Class-S
Location: access denied
Registered: 2007-01-23
Posts: 1154
Last visit: Today
Reputation: 28
Friendster

Re: Custom Cursor Script II (CrossHair Mouse Cursor)

cool trick ate phat.. hehe! thanks for sharing this.. =)




Kite rises against the wind, not with it..

#4  2009-01-04 10:49:08

---xXirukiTepe---
---xXirukiTepe---'s display avatar
» SuperFriendster
Anadipsic en Sarcophilous
Location: KARAKURA TOWN
Registered: 2007-11-01
Posts: 10892
Last visit: Yesterday
Reputation: 1302
Friendster

Re: Custom Cursor Script II (CrossHair Mouse Cursor)

wow.. saw it once in downloadjavascripts....
Thanks for bringin it up here.. :eh:

#5  2009-01-04 12:57:11

robin182
 mbe cobain
robin182's display avatar
» FriendsterAddict
sakid jiwa
school A
Location: pelangi
Registered: 2008-09-28
Posts: 401
Last visit: 2009-03-30
Reputation: 49
Friendster

Re: Custom Cursor Script II (CrossHair Mouse Cursor)

wew... cursor again from aidenlive...

nice and great...

thx for sharing..

:D


Encoder Bind Proc. FTP brute Sec. SQL PHP-code Feedback Self remove Logout

#6  2009-01-07 08:25:33

kayz09
 siLent maDneSs
kayz09's display avatar
» FriendsterTalker
asan aq?!!!
Barkada Trip
Location: piLipinas
Registered: 2008-06-08
Posts: 147
Last visit: 2009-06-20
Reputation: 10
Friendster

Re: Custom Cursor Script II (CrossHair Mouse Cursor)

tnx 4 this....:D




#7  2009-01-07 09:40:19

rebora2007
 Jimmy
rebora2007's display avatar
» FriendsterGeek
Location: France
Registered: 2007-06-15
Posts: 1217
Last visit: 2009-07-02
Reputation: 39
Friendster

Re: Custom Cursor Script II (CrossHair Mouse Cursor)

nice one thanks for sharing :)


#8  2009-01-09 15:57:31

msz.amick
 amick
» FriendsterNewbie
pix17
Location: manila
Registered: 2008-11-16
Posts: 18
Last visit: 2009-01-23
Reputation: 2
Friendster

Re: Custom Cursor Script II (CrossHair Mouse Cursor)

wow! nice one hehe


#9  2009-01-09 22:28:55

ilovefudgie14
 Sosixa-
ilovefudgie14's display avatar
» FriendsterTalker
i lab 09-
Artwork 101
Location: SOUTH KOREA! :))
Registered: 2008-02-03
Posts: 165
Last visit: 2009-06-24
Reputation: 17
Friendster

Re: Custom Cursor Script II (CrossHair Mouse Cursor)

nice..
thanxs for sharing.hehe =|

*xaxa


#10  2009-01-11 04:53:20

zholuterocripz
 zholutero_cripz
zholuterocripz's display avatar
» Cursed Member
Location: Dasmariñas, Cavite
Registered: 2008-12-31
Posts: 59
Last visit: 2009-06-30
Reputation: 1
Friendster

Re: Custom Cursor Script II (CrossHair Mouse Cursor)

thanks for sharing :paranoid:

Search Friendstertalk

Board footer

FriendsterTalk is not affiliated with Friendster.com
© 2002–2009 PunBB

[ 11 queries - 0.061 second ]
Powered by SyntheticNetwork

FriendsterTalk.com x

Welcome to FriendsterTalk! You'll need to login in order to fully use all the features and view all the sections of this site.

Please register if you're not yet a member. =)