Is it possible to set the cursor to "wait" on the entire html page in a simple way? The idea is to show the user that something happens when an ajax call is made. The code below presents a simplified version of what I tried, and also demonstrates the problems I am facing:
- if the element (# id1) has the cursor style set, it ignores the one that is set on the body (obviously)
- some elements have a default cursor style (a) and will not show a wait cursor when it hangs
- the body element has a certain height depending on the content, and if the page is short, the cursor will not appear below the footer
Test:
<html> <head> <style type="text/css"> #id1 { background-color: #06f; cursor: pointer; } #id2 { background-color: #f60; } </style> </head> <body> <div id="id1">cursor: pointer</div> <div id="id2">no cursor</div> <a href="#" onclick="document.body.style.cursor = 'wait'; return false">Do something</a> </body> </html>
Then edit ... It worked in firefox and IE with:
div#mask { display: none; cursor: wait; z-index: 9999; position: absolute; top: 0; left: 0; height: 100%; width: 100%; background-color:
The problem with (or feature) of this solution is that it will prevent clicks due to the overlapping div (thanks Kibbee)
Later, later edit ...
A simpler solution from Dorward:
.wait, .wait * { cursor: wait !important; }
and then
<a href="#" onclick="document.body.className = 'wait'; return false">Do something</a>
This solution only shows the wait cursor, but allows clicks.
javascript html css dynamic-css
Aleris Oct 10 '08 at 20:18 2008-10-10 20:18
source share