about random cursor code Hitskin_logo Hitskin.com

This is a Hitskin.com skin preview
Install the skinReturn to the skin page

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.
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 January 6th 2015, 12:59 pm

    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 January 23rd 2015, 1:31 pm; 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 January 7th 2015, 1:24 am

    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 January 7th 2015, 1:28 pm

    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 January 8th 2015, 5:30 am

    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 January 23rd 2015, 1:04 pm

    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 January 23rd 2015, 1:13 pm

    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 January 23rd 2015, 1:21 pm

    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 January 23rd 2015, 1:29 pm

    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 January 23rd 2015, 1:33 pm

    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 January 23rd 2015, 2:30 pm

    You're welcome

    Topic archived