反正有没有创建一个警报框,但具有更现代的风格?发出警告框后,用户在确认之前无法使用浏览器(输入密钥或单击"确定").我想以相同的方式锁定浏览器,但使用定制的,更好看的警报框.用javascript可以实现吗?
谢谢
编辑:澄清,通过锁定浏览器我的意思是无法更改网址,打开新标签等.用户需要确认才能切换到另一个页面
所以我在这里搜索了一些关于AlertDialog的问题,我不完全确定我在做什么,所以我很难将这些问题与我自己的例子联系起来.(我对这个整个Android编程还是新手,所以请耐心等待.)
我已经在public class _下定义了这个实现OnCLickListener的...
public AlertDialog myAlertDialog;
Run Code Online (Sandbox Code Playgroud)
然后我在onClick下有这个
public void onClick(View src) {
switch(src.getId()){
case R.id.buttonOk:
if (score==0){
AlertDialog.Builder myAlertDialog = new AlertDialog.Builder(this);
myAlertDialog.setTitle("Title");
myAlertDialog.setMessage("Message");
myAlertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
return;
} });
myAlertDialog.show();
}
Run Code Online (Sandbox Code Playgroud)
此行及其下方的行有错误:
myAlertDialog.setButton("OK", new DialogInterface.OnClickListener() {
Run Code Online (Sandbox Code Playgroud)
错误:
1st:此行的多个标记 - DialogInterface无法解析为类型 - 方法setButton(String,new OnClickListener(){})未定义类型
第二:DialogInterface无法解析为一个类型
任何人都可以告诉我,我做错了吗?
谢谢!
编写警报时,有什么简单的方法可以在用户未连接到Internet时向用户发出警告?我正在使用Xcode,现在当没有连接时,它只是uiwebview中的白色屏幕.
我需要show_alert()在PHP代码中引入JavaScript警报功能.怎么做到这一点?
script type="text/javascript">
function show_alert() {
var msg = "No solution found.";
alert(msg);
}
</script>
<?php
//...
$outputs = -1;
if ($outputs == -1) {
echo '<script type="text/javascript"> show_alert(); </script>';
} else {
?>
<table width="100%">
<tr>
<td width="100%">
<div class="scrollbar" id="chart">
<img src="ganttchart.php">
</div>
</td>
</tr>
</table>
<?php
}
?>
Run Code Online (Sandbox Code Playgroud) 我有40个带有css类的.myImage图像:
.myImage{
position:absolute;
}
Run Code Online (Sandbox Code Playgroud)
在jQuery我正在做:
$('.myImage').each(function(){
alert($(this).height());
});
Run Code Online (Sandbox Code Playgroud)
对于像前15张图像这样的东西我有很好的高度,但是在最后一张图像之前警报为0.而且我很确定每个图像都会显示,因为我用其他jQuery脚本给每个图像一个位置,它们都显示出来.
为什么15张图片后警报为0?
似乎AngularJS $ window.alert()和Javascript alert()是相同的.在什么条件下我们应该使用哪一个?或者没有任何区别?
在Stackoverflow中阅读此帖后,(检测文本输入字段中的Enter键)我试着让我的一些输入触发输入...我没有工作.我做了一个简单的例子,它仍然无效.有人可以暗示正确的方式吗?(仅供参考 - 绝对是新手)
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>On Enter</title>
<script src="../../Scripts/jquery-2.1.0.min.js"></script>
<script>
$(".input1").keyup(function (e) {
if (e.keyCode == 13) {
alert ("It Works");
}
});
</script>
</head>
<body>
<input type="text"
id="input1"
placeholder="Press Enter When Done">
</input>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
谢谢
我打电话给helloworld并用以下两种不同的方式定义它:
1)随变量
2)使用函数名称itseld
var helloWorld = function() {
return '2';
}
function helloWorld() {
return '1';
}
alert (helloWorld()); // This alert 2, but in absence of "var helloWorld = ....", it alert "1".
Run Code Online (Sandbox Code Playgroud)
任何人都可以解释为什么它调用var helloWord =?而不是函数helloWorld()?
谢谢 !!
我有这个HTML:
<input class="radio" type="radio" name="which_app" value="" id="whichApp1" required>
<label class="left-narrow" for="whichApp1">Program #1</label><br />
<input class="radio" type="radio" name="which_app" value="" id="whichApp2">
<label class="left-narrow" for="whichApp2">Program #2</label>
Run Code Online (Sandbox Code Playgroud)
我有这个脚本:
$( 'input[type=radio][name=which_app]' ).change( function() {
var label = $("label[for='"+$(this).attr('id')+"']");
alert( label );
}
Run Code Online (Sandbox Code Playgroud)
我收到此弹出警报:
如何解码[object Object]以获取被点击的标签?(还有其他原因value=""在这个时候不使用,所以我试图只关注它label.谢谢你)
我正在使用Java + JavaFX编写一个小应用程序.
在控制器类我有我的PasswordField:
@FXML
PasswordField password;
Run Code Online (Sandbox Code Playgroud)
以及临时存储密码的字段:
private String rootPassword;
Run Code Online (Sandbox Code Playgroud)
然后我有一个方法来处理密码:
private void handlePasswordField() {
if (!password.getText().isEmpty()) {
this.rootPassword = password.getText();
} else {
Alert alert = new Alert(AlertType.WARNING);
alert.initOwner(nbtcInstaller.getPrimaryStage());
alert.setTitle("No password");
alert.setHeaderText("No password provided");
alert.setContentText("Please enter a new ROOT password");
alert.showAndWait();
}
}
Run Code Online (Sandbox Code Playgroud)
以及按下"安装"按钮后启动的方法:
@FXML
private void handleCommand() {
handlePasswordField();
doAllTheOtherStuff();
Platform.exit();
}
Run Code Online (Sandbox Code Playgroud)
当我没有提供密码时,我会收到警报,但doAllTheOtherStuff()仍然会启动.doAllTheOtherStuff()如果没有提供密码,我该怎么做才能阻止它启动方法?