创建用户点击的方式全页面元素:
$('formId').observe(
'submit',
function() {
// create DIV with an id for possible later use
var blocker = new Element('div', {id: 'blocker'});
// expand to fill parent element
blocker.setStyle({
position: 'absolute',
left: 0,
top: 0,
width: '100%',
height: '100%',
zIndex: 1000 // overlay everything
});
// set whole body as parent
document.body.insert(blocker);
// prevent keyboard interaction too
this.blur();
}
);
现在很短的时间内表单提交没有人可以改变任何领域(除了通过运行脚本)。如果你喜欢,你甚至可以给DIV添加一个等待消息,否则它对用户是不可见的。
如果你通过AJAX提交表单我还添加了一个id
使得AJAX完成时,你可以$('blocker').remove();
我不是'prototype'的家伙,但你就不能回' FALSE'? – gdoron 2012-03-13 23:12:56