我希望在用户点击之前的按钮后启用按钮,并且功能的执行结束。换句话说,只有满足两个条件时才能启用该按钮:按下上一个按钮+执行功能。
我已经为第一个条件做了这件事,但我不知道如何强制这两个条件而不只是一个......
以下是代码:
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="css/prelude.css">
<link rel="stylesheet" href="css/rainbow.css">
<link rel="stylesheet" href="../css/progress.css">
<style type="text/css">
body {
padding: 40px;
}
.pie_progress {
width: 160px;
margin: 10px auto;
}
@media all and (max-width: 768px) {
.pie_progress {
width: 80%;
max-width: 300px;
}
}
</style>
</head>
<body>
<section>
<section>
<div class="row">
<div class="pie_progress--slow" role="progressbar" data-barcolor="#3daf2c" data-barsize="20">
<span class="pie_progress__number">0%</span>
</div>
</div>
</section>
</section>
<center><input type="button" id="button1" value="Check Compatibility" onclick="enableButton2()"/><br>
<input type="button" id="button2" value="Perform Security Tests" disabled onclick="window.open('./page.html');" target="_blank" /></center>
<script type="text/javascript" src="js/rainbow.min.js"></script>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="../src/jquery-asPieProgress.js"></script>
<script type="text/javascript">
jQuery(document).ready(function($){
// Example with grater loading time - loads longer
$('.pie_progress--slow').asPieProgress({
namespace: 'pie_progress',
goal: 1000,
min: 0,
max: 1000,
speed: 1200,
easing: 'linear'
});
$('.pie_progress').asPieProgress('start');
});
</script>
</body>
</html>
我创建的功能:
function enableButton2() {
var information = String(navigator.userAgent);
var checkOS = information.includes("Linux",0);
var checkBrowser = information.includes("Firefox",0);
if(checkOS && checkBrowser){
alert("Your system meets the minimum requirements! :)");
document.getElementById("button2").disabled = false;
}
else{
alert("Your System is not compatible");
}
}