在我的网页中,我有一个忙碌的指示器,如下所示:
window.onload = setupFunc;
function setupFunc() {
document.getElementsByTagName('body')[0].onclick = clickFunc;
hideBusysign();
}
function hideBusysign() {
document.body.style.cursor='default';
}
function showBusysign() {
document.body.style.cursor='progress';
}
function clickFunc(eventData) {
var clickedElement = (window.event) ? event.srcElement : eventData.target;
if ((clickedElement.tagName.toUpperCase() == 'BUTTON' || clickedElement.tagName.toUpperCase() == 'A' ) || clickedElement.parentNode.tagName.toUpperCase() == 'A'
|| (clickedElement.tagName.toUpperCase() == 'INPUT' && (clickedElement.type.toUpperCase() == 'BUTTON' || clickedElement.type.toUpperCase() == 'SUBMIT')))
&& clickedElement.parentNode.id.toUpperCase() != 'NOBUSY' ) {
showBusysign();
}
}
(为了简单起见,我删除了 ajax 请求的部分)
最佳答案
我终于自己找到了一个非常简单且工作良好的解决方案:
window.onbeforeunload = showBusysign;
function showBusysign() {
document.body.style.cursor='progress';
}
:-)
如果它可能对 wicket 程序员有帮助,这是我的整个脚本:
window.onload = setupFunc; // for ajax requests
window.onbeforeunload = showBusysign; // for page requests
function setupFunc() {
Wicket.Event.subscribe('/ajax/call/beforeSend', function( attributes, jqXHR, settings ) {
showBusysign()
});
Wicket.Event.subscribe('/ajax/call/complete', function( attributes, jqXHR, textStatus) {
hideBusysign()
});
}
function hideBusysign() {
document.body.style.cursor='default';
}
function showBusysign() {
document.body.style.cursor='progress';
}
关于css - 如果 onclick 返回 false,则禁用 href 上的繁忙指示器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39491983/