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.

about random cursor code

2 posters

Go down

Solved about random cursor code

Post by Michael_vx Tue Jan 06, 2015 4:59 am

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 Jan 23, 2015 5:31 am; edited 1 time in total
Michael_vx
Michael_vx
Forumember

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

Back to top Go down

Solved Re: about random cursor code

Post by Ange Tuteur Tue Jan 06, 2015 5:24 pm

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
Ange Tuteur
Ange Tuteur
Forumaster

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

https://fmdesign.forumotion.com

Back to top Go down

Solved Re: about random cursor code

Post by Michael_vx Wed Jan 07, 2015 5:28 am

Very Happy
i think i missed to say more info
if more then 5
is it gonna work ?
Michael_vx
Michael_vx
Forumember

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

Back to top Go down

Solved Re: about random cursor code

Post by Ange Tuteur Wed Jan 07, 2015 9:30 pm

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);
  }
})();
Ange Tuteur
Ange Tuteur
Forumaster

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

https://fmdesign.forumotion.com

Back to top Go down

Solved Re: about random cursor code

Post by Michael_vx Fri Jan 23, 2015 5:04 am

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
Michael_vx
Michael_vx
Forumember

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

Back to top Go down

Solved Re: about random cursor code

Post by Ange Tuteur Fri Jan 23, 2015 5:13 am

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)
Ange Tuteur
Ange Tuteur
Forumaster

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

https://fmdesign.forumotion.com

Back to top Go down

Solved Re: about random cursor code

Post by Michael_vx Fri Jan 23, 2015 5:21 am

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
Michael_vx
Michael_vx
Forumember

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

Back to top Go down

Solved Re: about random cursor code

Post by Ange Tuteur Fri Jan 23, 2015 5:29 am

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)
Ange Tuteur
Ange Tuteur
Forumaster

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

https://fmdesign.forumotion.com

Back to top Go down

Solved Re: about random cursor code

Post by Michael_vx Fri Jan 23, 2015 5:33 am

all clear to me Smile
thanks a lot
100%
solved
Michael_vx
Michael_vx
Forumember

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

Back to top Go down

Solved Re: about random cursor code

Post by Ange Tuteur Fri Jan 23, 2015 6:30 am

You're welcome

Topic archived
Ange Tuteur
Ange Tuteur
Forumaster

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

https://fmdesign.forumotion.com

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum