Flash Games

 FAQ   Search   Members   Groups   Register  User Control Panel      Login 

Your time now:
Mon Nov 23, 2009 9:19 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 6 posts ]  Bookmark and Share
Author Message
 Post subject: random cursors using CSS
PostPosted: Wed Aug 13, 2008 2:41 pm 
Offline

Joined: Sat Jul 26, 2008 11:37 pm
Posts: 5
Hello,

here is what i want to do. i would like to load a random cursor on my webpage when the page is reloaded. how can the following statement be used to randomly select a cursor:

element.style.cursor = 'url(' + cursor1 + ')';

where cursor1 is the url/name of the location and name of the cursor.

this is what i am using now for my cursor statement:

<style type="text/css"> body { cursor: url('graphics/cursor/romantic_1.cur'); } a { cursor: url('graphics/cursor/bible_1.cur'); }</style>

how can i change the above statement to reflect the samething, but at random?

_________________
Thanks,
John....


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 14, 2008 1:06 am 
Offline
500+ Club
User avatar

Joined: Wed Feb 27, 2008 6:14 am
Posts: 929
Location: Cebu City Philippines
Please read notes on the code:
Code:
<script type="text/javascript">
var rangCur=[
/* Place all the url of the cursor in this array */
'graphics/cursor/romantic_1.cur',
'graphics/cursor/bible_1.cur'
];
window.onload=function() { rangRand=Math.floor(Math.random()*rangCur.length);
document.body.style.cursor='url('+rangCur[rangRand]+')';}
</script>

_________________
~ Get me some work, I do freelancing ~


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 14, 2008 1:52 am 
Offline

Joined: Sat Jul 26, 2008 11:37 pm
Posts: 5
<script type="text/javascript">
var rangCur=['graphics/cursor/romantic_1.cur', 'graphics/cursor/bible_1.cur'];
window.onload = function()
{
rangRand = Math.floor(Math.random() * rangCur.length);
document.body.style.cursor='url(' + rangCur[rangRand] + ')';

</script>


is the code placed in the <head> or <body> section.... if the <head> is it placed before the </head> or if the <body> is it placed after the <body> or just above the </body>.... cause its not working, its showing the default cursor....

_________________
Thanks,
John....


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 14, 2008 2:00 am 
Offline
500+ Club
User avatar

Joined: Wed Feb 27, 2008 6:14 am
Posts: 929
Location: Cebu City Philippines
Well, it was working for me, but not on FF.

_________________
~ Get me some work, I do freelancing ~


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 14, 2008 2:44 am 
Offline

Joined: Sat Jul 26, 2008 11:37 pm
Posts: 5
i got it to work... i had 2 window.onload calls and the one was causeing the other not to work.... i commented the one <!--window.onload--> out and the cursor displayed correctly...

_________________
Thanks,
John....


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 14, 2008 2:49 am 
Offline

Joined: Sat Jul 26, 2008 11:37 pm
Posts: 5
now if i can just figure out how to get this to work the same way:

a { cursor: url('graphics/cursor/bible_1.cur'); }

where bible_1.cur is also random when the cursor is placed over a link....

_________________
Thanks,
John....


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group - Flash Games - TNX Invitation Code - TNX Review


Webmaster - Excruciating - Johnathan - Kotik - Ash - Tomi - rangana - Phate - dflynn - Medley