简体   繁体   English

提交表单时如何使用JavaScript禁用页面内容

[英]How to disable page content using javascript when the form is submitted

In my application when i click form submit, service call happens. 在我的应用程序中,当我单击“表单提交”时,就会发生服务呼叫。 When the service call happens I need to I need to disable the page conetent til the next page loads. 发生服务呼叫时,我需要禁用页面提示直到下一页加载。

As i have given cursor:wait the mouse pointer changes to loading symbol and does not allow to click on the page. 正如我给定的cursor:wait一样,鼠标指针变为加载符号,并且不允许单击页面。 But still i could use tab and enter or change the values in the page. 但是我仍然可以使用tab并在页面中输入或更改值。

Can anyone tell the code to disable page content using transparent image? 谁能告诉代码使用透明图像禁用页面内容?

You could do that easier than with a transparent image : 您可以比使用透明图像更容易做到这一点:

$('body.waiting > *').on('click', function(e) {
    e.preventDefault();
});

I think that you should only disable the submit input for example : 我认为您应该仅禁用提交输入,例如:

$('input').attr('disabled', 'disabled');

With a "overlay", add an absolute div at the top of your page : 使用“覆盖”,在页面顶部添加一个绝对div:

<div id="overlay" style="position:absolute;background:url('trans.png');left:0;top:0;width:100%;height:100%;display:none;"></div>

And than simply show it when your form is submitted : 而不是在提交表单时简单地显示它:

$('#overlay').show();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用JavaScript提交表单时如何更新div的内容 - How to update the content of a div when a form is submitted using javaScript 使用提交按钮提交表单时,如何将javascript变量发送到php中的另一页 - How to send javascript variable to another page in php when form is submitted using submit button 提交表单时如何将值传递给同一页? 使用Ajax - How to pass a value to the same page when a form submitted? Using Ajax 提交PHP表单并刷新页面后,可以使用javaScript隐藏该表单吗? - Can I hide the form using javaScript when a PHP form has been submitted and the page refreshes? 提交表单后如何加载页面内容? - How to load the contents of a page when a Form is submitted? 提交表单后如何停止重定向页面? - How to stop Redirecting a page when a form is submitted? 提交表单后如何使用JavaScript进行验证? - How to do validation with JavaScript when the form is submitted? 引导模式在页面加载时自动打开,但是如果提交表单如何禁用 - Bootstrap modal opens automatically on page load, but how to disable if form is submitted 提交重力表后,在同一页面上显示内容 - When Gravity Form is submitted then reveal content on same page 提交表单时停留在页面的特定部分 Javascript - Stay on a specific part of the page when the form is submitted Javascript
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM