用户单击提交时的等待指示器

Wait Indicator when user click submit

本文关键字:等待 指示器 单击 提交 用户      更新时间:2023-09-26

我有一个带有 Web 视图的应用程序,我在其中显示反馈 HTML 页面,当用户触摸 HTML 提交按钮时,我只需要显示一个等待指示器,也许更好的是禁用 HTML 表单中的提交按钮。

无论是来自iOS端还是HTML/Javascript端的解决方案都可以。

提交 HTML 表单后,当前页面上的所有执行都将停止。不能继续执行计时器脚本。

大多数浏览器已经显示繁忙指示器。

iOS 在 UIKit 中包含了一个用于标准微调器的控件,称为 UIActivityIndicatorView . https://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIActivityIndicatorView_Class/Reference/UIActivityIndicatorView.html。您将调用实例的 startAnimating 和 stopAnimating 方法,分别开始和结束动画。

如果要

在 iOS 中以编程方式创建活动指示器:

UIActivityIndicatorView *myIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]];
myIndicator.center = CGPointMake(160, 240);
myIndicator.hidesWhenStopped = NO;
[self.view addSubview:myIndicator];

然后启动/停止它:

[myIndicator startAnimating];
[myIndicator stopAnimating];

如前所述,您不必禁用HTML表单提交按钮,该页面上没有进一步的执行。

如果你有一个名称和ID为"myForm"的表单,一个ID为"myButton"的按钮(该按钮不能是类型或名称"submit")和一个id为"waitMessage"的空div,你可以在其中插入等待消息或gif,那么你可以使用这样的东西:

var myButton1 = document.getElementById("myButton");
myButton1.onclick = function (){
   getElementById("waitMessage").innerHTML = "Whatever waiting message or html code you want";
   myButton1.disabled=true;
   document.forms["myform"].submit();
}