This is in a browser. I want to change the cursor while I do some processing. So I found the following code:
The author then amended this saying to use the following for compatibility:
Now, I've been thinking about an idea for a while, but I don't see it used very often. I thought I'd take the chance to try to implement it. Instead of doing the object detect each and every time, why not do it once? Here's what I came up with:
I wanted to do
[tt] getCursor() = 'wait';[/tt]
but that failed as did
[tt] (getCursor()) = 'wait';[/tt]
So anyway, does anyone have any ideas for me? I have studied up on javascript a bit but I am actually fairly inexperienced so I would love a critique or some ideas.
Code:
function cursor_wait() {
document.body.style.cursor = 'wait';
}
function cursor_clear() {
document.body.style.cursor = 'default';
}
Code:
var cursor =
document.layers ? document.cursor :
document.all ? document.all.cursor :
document.getElementById ? document.getElementById('cursor') : null;
Code:
var getCursor = function(){
if(document.layers) {return function(){return document.cursor;};}
if(document.all) {return function(){return document.all.cursor;};}
if(document.getElementById) {return function(){return document.getElementById('cursor');};}
return function(){return null;};
}();
function cursorWait() {
var cursor = getCursor();
cursor = 'wait';
}
function cursorClear() {
var cursor = getCursor();
cursor = 'default';
}
[tt] getCursor() = 'wait';[/tt]
but that failed as did
[tt] (getCursor()) = 'wait';[/tt]
So anyway, does anyone have any ideas for me? I have studied up on javascript a bit but I am actually fairly inexperienced so I would love a critique or some ideas.