这是我的 JavaScript 代码,我尝试播放声音然后显示警报,但我总是先收到警报,当我单击“确定”时,就会播放声音。
<script>
function play() {
var audio = document.getElementById("audio");
audio.play();
alert('Extraction is finished');
}
</script>
Run Code Online (Sandbox Code Playgroud)
我在 oncomplete 命令按钮中调用此函数。我需要先播放声音,然后显示警报或同时显示两者。我怎样才能让这个工作???
我在从 UIAlertController 获取文本字段值时遇到问题。我正在获取该值,但它似乎以错误的顺序执行我的代码。在下面的函数中,我希望函数调用返回一个字符串,但该值在函数返回时并未设置。
@IBAction func btnSaveSession(sender: AnyObject) {
//Prompt user to enter session name
var sessionName: String = ""
sessionName = promptUserToEnterSessionName("Save Session", message: "Please enter the name of your custom session below.");
print("session Name: " + sessionName)
//Save session to firebase.
//redirect to create session controller.
}
func promptUserToEnterSessionName(title: String, message: String) -> String{
var sessionName: String = ""
//1. Create the alert controller.
let alert = UIAlertController(title: title, message: message, preferredStyle: .Alert)
//2. Add the text field. You …Run Code Online (Sandbox Code Playgroud) 我想使用 Bootstrap 发出结束警报。警报显示正确,但我无法关闭它。这段代码有什么问题吗?谢谢。
<div class="alert alert-warning alert-dismissable">
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
<strong>Warning!</strong>
</div>
Run Code Online (Sandbox Code Playgroud) 我试图在尝试存储过程后显示成功/不成功的消息。单击“保存”按钮时会调用“保存 ActionResult” - 但是在重定向回索引之前,我想显示一个消息框。有没有办法先返回视图,然后再返回RedirectToAction?
保存按钮指向:
[HttpPost]
public ActionResult Save(string submit, Models.KnownIssues knownIssue)
{
UpdateKnownIssue(knownIssue);
InsertKnownIssue(knownIssue);
return RedirectToAction("Index");
}
Run Code Online (Sandbox Code Playgroud)
视图袋警告:
public ActionResult Edit(KnownIssues knownIssue, string submit)
{
if (UpdateKnownIssue(knownIssue))
{
ViewBag.ShowAlert = "<script>alert('Successfully Edited'); window.location.href = '/KnownIssues';</script>";
} else
{
ViewBag.ShowAlert = "<script>alert('Unseccessful. Try again.');</script>";
}
return View(knownIssue);
}
Run Code Online (Sandbox Code Playgroud) 正如标题所述,我想知道隐藏警报的最佳方法,以便我们可以在不重新加载页面的情况下获得另一个警报。这里有几个针对 BS3 的答案,但我希望 BS4 有更好的解决方案。
这是我的 HTML:
<div style="display: none;" class="alert alert-danger alert-with-icon" data-notify="container">
<div class="container">
<div class="alert-wrapper">
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<i class="nc-icon nc-simple-remove"></i>
</button>
<div class="message"><i class="nc-icon nc-bell-55"></i>
My alert message.
</div>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我用它来触发打开警报:
$('.alert').show();
Run Code Online (Sandbox Code Playgroud) 现在我收到错误:警告:尝试在 CollectionViewController 上呈现 UIAlertController:0x7f9af9016200:0x7f9af750d620 已经呈现(空)
有没有办法快速堆叠警报?有我的代码,如果项目发布时间超过一天,它会显示警报。我尝试过两种方法但没有成功。
任何解决方案如何管理做到这一点?
for p in json! {
if self.checkDaysPassed(postDate: p["uploadedTime"] as! String) > 1 {
print("more than one day passed, sell item?")
let alert = UIAlertController(title: "Sell this item", message: "This item has been unused for a day", preferredStyle: .alert)
alert.modalPresentationStyle = UIModalPresentationStyle.overCurrentContext
alert.addAction(UIAlertAction(title: "Yes", style: .default){ (action) in
print("pressed yes")
})
alert.addAction(UIAlertAction(title: "No", style: .cancel){ (action) in
print("pressed no")
})
self.present(alert, animated: true)
}
}
Run Code Online (Sandbox Code Playgroud) 如果用户拒绝相机访问,我将显示一个带有取消和设置按钮的警报以显示它。但代码不起作用。
@IBAction func ProfileImageButton(_ sender: UIButton) {
print("profile image Button is pressed")
let imagePickerController = UIImagePickerController()
imagePickerController.delegate = self
profileimgbool = true
let actionSheet = UIAlertController(title: "Photo Source", message: "choose a Source", preferredStyle: .actionSheet)
actionSheet.addAction(UIAlertAction(title: "Camera", style: .default, handler: {(action:UIAlertAction) in imagePickerController.sourceType = .camera
self.present(imagePickerController, animated: true, completion: nil)
}))
actionSheet.addAction(UIAlertAction(title: "Photo Library", style: .default, handler: {(action:UIAlertAction) in imagePickerController.sourceType = .photoLibrary
self.present(imagePickerController, animated: true, completion: nil)}))
actionSheet.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil))
self.present(actionSheet, animated: true, completion: nil)
}
func checkCameraPermission() …Run Code Online (Sandbox Code Playgroud)
我在 Windows 10 上运行的 JavaFX 中有一个小应用程序,我已经更改了应用程序内部的许多内容,现在我面临的问题是我的 InfoBox 显示标题和图片,但框中没有文字。
我在我的应用程序的一部分中调用它:
infoBox("Karte wurde gelesen... bitte warten ", "Information-NFC", "Information-NFC!");
Run Code Online (Sandbox Code Playgroud)
这是函数本身:
public void infoBox(String infoMessage, String titleBar, String headerMessage)
{
Alert alert = new Alert(AlertType.INFORMATION);
alert.setResizable(true);
alert.getDialogPane().setPrefSize(480, 320);
alert.getDialogPane().setStyle("-fx-text-fill: red;-fx-font-size: 15px; -fx-font: 10px Tahoma; ");
alert.setTitle(titleBar);
alert.setHeaderText(headerMessage);
alert.setContentText(infoMessage);
System.out.println(infoMessage+"here");
//Logo für Programm Fenster
//////////// Logo ProgrammFesnter end
Image img2 = new Image(getClass().getResourceAsStream("logo.PNG"));
Stage dialogStage = (Stage) alert.getDialogPane().getScene().getWindow();
dialogStage.getIcons().add(img2);
alert.show();
try {
Thread.sleep(8000);
} catch (InterruptedException ex) {
System.out.println(ex);
}
alert.close();
}
Run Code Online (Sandbox Code Playgroud)
我可以在日志窗口中看到设置了变量“infoMessage”,但警报框本身是空的。我不知道为什么。你们中有人以前遇到过这个问题吗?
除了这个小盒子外,一切都运行良好...... …
我有以下表达:
(avg_over_time(my_metrics{service_name="aService"}[5m])) - (avg_over_time(my_metrics{service_name="aService"}[48h])) / (stddev_over_time(my_metrics{service_name="aService"}[48h]))
Run Code Online (Sandbox Code Playgroud)
每隔 48 小时检测一次异常情况。我正在努力理解如何编写在检测到异常时发出的警报。或者我完全错了,这已经可以使用了,因为当检测到异常时它会触发?
谢谢
我没有使用"form"标签创建了这种形式
我需要在Hello ____之间的警报框中添加一个中断.您的电子邮件地址是:.是否可以这样做?我试过br标签和\n但似乎什么都没有用
<head>
<title>Welcome Sheet</title>
</head>
<body>
<h1> Form Details</h1>
Run Code Online (Sandbox Code Playgroud)
名字
<br>
<input type="text" id="fname" placeholder="eg.John">
<br><br>
Run Code Online (Sandbox Code Playgroud)
姓
<br>
<input type="text" id="lname" placeholder="eg.Doe">
<br><br>
Run Code Online (Sandbox Code Playgroud)
电子邮件地址
<br>
<input type="email" id="email" placeholder="eg.johndoe@example.com">
<br><br>
<button onclick="myFunction()">Submit</button>
<script>
function myFunction() {
alert("Hello" + " " + document.getElementById("fname").value+ " " + document.getElementById("lname").value +" "+ "Your email address is:" + " " + document.getElementById("email").value);
}
</script>
</body>
Run Code Online (Sandbox Code Playgroud)
alert ×10
javascript ×3
css ×2
html ×2
swift ×2
asp.net-mvc ×1
audio ×1
bootstrap-4 ×1
function ×1
ios ×1
iphone ×1
javafx ×1
objective-c ×1
prometheus ×1
xcode ×1