我有一个带文本字段和两个按钮的AlertController:CANCEL和SAVE.这是代码:
@IBAction func addTherapy(sender: AnyObject)
{
let addAlertView = UIAlertController(title: "New Prescription", message: "Insert a name for this prescription", preferredStyle: UIAlertControllerStyle.Alert)
addAlertView.addAction(UIAlertAction(title: "Cancel",
style: UIAlertActionStyle.Default,
handler: nil))
addAlertView.addAction(UIAlertAction(title: "Save",
style: UIAlertActionStyle.Default,
handler: nil))
addAlertView.addTextFieldWithConfigurationHandler({textField in textField.placeholder = "Title"})
self.presentViewController(addAlertView, animated: true, completion: nil)
}
Run Code Online (Sandbox Code Playgroud)
我想要做的是在文本字段为空时执行检查以禁用SAVE按钮,就像想要创建NewAlbum的iOS的图片应用程序一样.请有人能解释一下该怎么办?
我有这个链接:
<p id="accept-favor"><a title="Accept this Favor" href="?wp_accept_favor=<?php comment_ID(); ?>">Accept this Favor</a></p>
我想在用户点击它时显示一个JavaScript警告框:"您确定要接受此回复作为您的帮助吗?" 有两个按钮,一个说"是",这将允许该功能运行,另一个说"否",这将取消回发并保持用户在页面上.
我该怎么做?谢谢 :)
在我的几个控制器中,我有重定向/ flash消息
redirect_to products_url, :notice => "message here",
redirect_to states_url, :error => "oops!" etc...
Run Code Online (Sandbox Code Playgroud)
但是,在我的会话控制器中,成功验证后,我有flash [:success] ="welcome!" redirect_to用户
我希望能够在我的其他控制器中做类似的事情:success =>"yay!"
这主要是为了美观/一致性目的,但是:注意,:警告和:错误唯一可用的闪存类型/我可以添加其他类型吗?我有道理吗?
谢谢!
在我的Rails 3应用程序中,我做:
render :js => "alert(\"Error!\\nEmpty message sent.\");" if ...
Run Code Online (Sandbox Code Playgroud)
有时,在此错误消息下(在同一个警告框中),我看到:"阻止此页面创建其他对话框"和一个复选框.
这是什么意思 ?
是否可以不显示此附加文本和复选框?
我使用的是Firefox 4.
我在iPhone Safari中运行一个网页.该页面有一个按钮.单击它,将显示一个警告消息框.还行吧.然后,我通过在地址栏中输入来更改或添加#hash URL ,然后,警报消息框停止工作.我点击按钮,没有任何反应.没有javascript错误但没有警告消息框.
这个iOS Safari是否已知问题?
请分享您的想法和您提出的解决方案.非常感谢!
$(".button").click(function () {
alert('Hello');
});Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.2.3/jquery.min.js"></script>
<input class="button" type="button" value="alert" />Run Code Online (Sandbox Code Playgroud)
注意:
我是Javascript的新手.
我试图编码这四个按钮.我现在正在第二个.我编写了一个数组.但是当我点击按钮时,它会替换页面.我想在警告框中显示该数组.
<html>
<head>
<script type="text/javascript">
function SayHello()
{
alert("Hello World!");
}
function DumpCustomers()
{
var aCustomers=new Array();
aCustomers[0]="Frank Sinatra ";
aCustomers[1]="Bob Villa ";
aCustomers[2]="Kurt Cobain ";
aCustomers[3]="Tom Cruise ";
aCustomers[4]="Tim Robbins ";
aCustomers[5]="Santa Claus ";
aCustomers[6]="Easter Bunny ";
aCustomers[7]="Clark Kent ";
aCustomers[8]="Marry Poppins ";
aCustomers[9]="John Wayne ";
document.write(aCustomers[0]);
document.write(aCustomers[1]);
document.write(aCustomers[2]);
document.write(aCustomers[3]);
document.write(aCustomers[4]);
document.write(aCustomers[5]);
document.write(aCustomers[6]);
document.write(aCustomers[7]);
document.write(aCustomers[8]);
document.write(aCustomers[9]);
}
function DisplayFishCounts()
{
}
function FindJonGalt()
{
}
</script>
</head>
<body>
<form name="Main">
<input type="button" id=1 onclick="SayHello();" value="Say Hi"/>
<input type="button" …Run Code Online (Sandbox Code Playgroud) 我正在使用alert()将验证错误输出回用户,因为我的设计没有提供其他任何内容,但我宁愿使用jQuery UI对话框作为我的消息的警告对话框.
由于错误不包含在(html)div中,我不知道该怎么做.通常你会分配dialog()到一个div说$("#divName").dialog()但我更需要一个alert_dialog("Custom message here")类似的东西或类似的东西.
有任何想法吗?
这段代码
alert("Hello again! This is how we" + "\n" + "add line breaks to an alert box!");Run Code Online (Sandbox Code Playgroud)
不起作用.Firefox JavaScript控制台名称错误为"未终止的字符串文字",并指向"符号之前\n.我想用多行文本触发警报.请不要使用jQuery.
应用程序脚本 Web 应用程序在<iframe>. Chrome 似乎不再支持alert(), confirm(), 在 web app 上推广这些功能。
有什么解决方法吗?
试图替换alert()用window.alert(),但仍然无法正常工作。
exec:1 一个不同的源子框架试图创建一个 JavaScript 对话框。这不再被允许并被阻止。有关更多详细信息,请参阅https://www.chromestatus.com/feature/5148698084376576。