The forum of the forums

Would you like to react to this message? Create an account in a few clicks or log in to continue.
The forum of the forums
2 posters

    about random cursor code

    Michael_vx
    Michael_vx
    Forumember


    Male Posts : 659
    Reputation : 29
    Language : Arabic and some English
    Location : Egypt

    Solved about random cursor code

    Post by Michael_vx Tue 6 Jan - 12:59

    hi there
    i forget to ask about something here
    https://help.forumotion.com/t136449-decorate-your-forum-for-halloween
    Terrifyingly random cursor :
    if i like to add more cursors or use something like cursor.cru
    or cursor.ani
    is this gonna work ?
    i did not try it yet but i like to know before i try
    thanks


    Last edited by Michael_vx on Fri 23 Jan - 13:31; edited 1 time in total
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: about random cursor code

    Post by Ange Tuteur Wed 7 Jan - 1:24

    Hi @Michael_vx,

    You can replace the cursors :
    Code:
         cursor1 = 'http://i39.servimg.com/u/f39/18/21/60/73/curseu10.png',
     Â     cursor2 = 'http://i39.servimg.com/u/f39/18/21/60/73/curseu11.png',
     Â     cursor3 = 'http://i39.servimg.com/u/f39/18/21/60/73/curseu12.png',
     Â     cursor4 = 'http://i39.servimg.com/u/f39/18/21/60/73/curseu13.png',
     Â     cursor5 = 'http://i39.servimg.com/u/f39/18/21/60/73/curseu14.png',

    With any image or valid cursor file that you like. Smile
    Michael_vx
    Michael_vx
    Forumember


    Male Posts : 659
    Reputation : 29
    Language : Arabic and some English
    Location : Egypt

    Solved Re: about random cursor code

    Post by Michael_vx Wed 7 Jan - 13:28

    Very Happy
    i think i missed to say more info
    if more then 5
    is it gonna work ?
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: about random cursor code

    Post by Ange Tuteur Thu 8 Jan - 5:30

    Add more variables and more conditions for multiple cursors.

    Example :
    Code:
    (function() {
     Â var cursor1 = 'http://i39.servimg.com/u/f39/18/21/60/73/curseu10.png',
     Â     cursor2 = 'http://i39.servimg.com/u/f39/18/21/60/73/curseu11.png',
     Â     cursor3 = 'http://i39.servimg.com/u/f39/18/21/60/73/curseu12.png',
     Â     cursor4 = 'http://i39.servimg.com/u/f39/18/21/60/73/curseu13.png',
     Â     cursor5 = 'http://i39.servimg.com/u/f39/18/21/60/73/curseu14.png',
     Â     cursor6 = 'image link',
     Â     cursor7 = 'image link',
     Â     cursor8 = 'image link',
     Â     cursor9 = 'image link',
     Â     cursor10 = 'image link',
     Â     r = Math.floor(Math.random()*10);

     Â     if (r == 0) setCursor(cursor1);
     Â     if (r == 1) setCursor(cursor2);
     Â     if (r == 2) setCursor(cursor3);
     Â     if (r == 3) setCursor(cursor4);
     Â     if (r == 4) setCursor(cursor5);
     Â     if (r == 5) setCursor(cursor6);
     Â     if (r == 6) setCursor(cursor7);
     Â     if (r == 7) setCursor(cursor8);
     Â     if (r == 9) setCursor(cursor9);
     Â     if (r == 9) setCursor(cursor10);

     Â function setCursor(cursor) {
     Â   var s = document.createElement('STYLE');
     Â   s.type = 'text/css';
     Â   s.innerHTML = 'body, *:hover {cursor:url('+cursor+'),auto !important}';
     Â   document.head.appendChild(s);
     Â }
    })();
    Michael_vx
    Michael_vx
    Forumember


    Male Posts : 659
    Reputation : 29
    Language : Arabic and some English
    Location : Egypt

    Solved Re: about random cursor code

    Post by Michael_vx Fri 23 Jan - 13:04

    sorry for delay im *****up with my internet problems Sad
    and my last question just so i can make sure that i understand everything
    is that line must have same number as the cursor i mean this line
    Code:
          r = Math.floor(Math.random()*10);
    so if i used 15 then ill need to change the 10 to 15 am I right
    Code:
          if (r == 1) setCursor(cursor2);
    this is about the changing ?
    i apologize again for my delay
    my network is being online like less then a week each month Sad
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: about random cursor code

    Post by Ange Tuteur Fri 23 Jan - 13:13

    I made a mistake in the last code, but you have it correct.

    If you have 15 cursors, you should change the number in r to :
    Code:
    r = Math.floor(Math.random()*16);
    ( It should always be 1 number higher than what you have )

    These are conditions, if r(the random number) is equal to N we set a cursor. For example :
    Code:
    if (r == 0) setCursor(cursor1)
    Michael_vx
    Michael_vx
    Forumember


    Male Posts : 659
    Reputation : 29
    Language : Arabic and some English
    Location : Egypt

    Solved Re: about random cursor code

    Post by Michael_vx Fri 23 Jan - 13:21

    is the conditions are must be used ?
    if yes
    then i don`t have any other question Smile and topic is solved
    if no
    then tell me more info and still topic solved
    thanks a lot
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: about random cursor code

    Post by Ange Tuteur Fri 23 Jan - 13:29

    Of course the conditions are necessary. They're used to assign a number to the cursor, so to say.

    for example, if we want cursor 2 to be used, we'll need to set a condition so it can be used if r is 1.
    Code:
    if (r == 1) setCursor(cursor2)

    You should do this for every new cursor you add. For example, up to 15 cursors, well end with :
    Code:
    if (r == 16) setCursor(cursor15)
    Michael_vx
    Michael_vx
    Forumember


    Male Posts : 659
    Reputation : 29
    Language : Arabic and some English
    Location : Egypt

    Solved Re: about random cursor code

    Post by Michael_vx Fri 23 Jan - 13:33

    all clear to me Smile
    thanks a lot
    100%
    solved
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: about random cursor code

    Post by Ange Tuteur Fri 23 Jan - 14:30

    You're welcome

    Topic archived

      Current date/time is Mon 23 Sep - 10:27