/    Sign up×
Community /Pin to ProfileBookmark

changing mouse cursor

Hi,
I want to change style of cursor while doing some javascript.
I made an example.

<html><head><script language=”javascript” type=”text/javascript”>
function go() {
document.getElementById(“info”).innerText = self.document.body.style.cursor;
self.setTimeout( “cont1()”, 5000 );
}

function cont1() {
self.document.body.style.cursor = “wait”;
document.getElementById(“info”).innerText = self.document.body.style.cursor;
self.setTimeout( “cont2()”, 5000 );
}

function cont2() {
self.document.body.style.cursor = “auto”;
document.getElementById(“info”).innerText = self.document.body.style.cursor;
}

</script></head>
<body onload=”go()”>
hello World, cursor style is: “<span id=”info”></span>”
</body></html>

If you start the script move mousecursor into browserwindow and wait. After 5 seconds style is changed but cursor is still ‘arrow’, you had to move mouse a bit and you get ‘hourglas’-style.

Is there a way to change cursorstyle without moving mouse?
Thanks, skriptor.

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@FangMay 19.2003 — An event has to fire to initiate the change; mouseover, keypress etc.
Copy linkTweet thisAlerts:
@skriptorauthorMay 19.2003 — Hi Fang,

this sounds easy. I tried some changes to my code, but there was no real solution.

Please could you add a line of code to my example ?

Thank you, skriptor
×

Success!

Help @skriptor spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...