js中關閉彈窗
<!DOCTYPE?html?PUBLIC?"-//W3C//DTD?XHTML?1.0?Transitional//EN"?"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html?xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta?http-equiv="Content-Type"?content="text/html;?charset=utf-8"?/>
<title>無標題文檔</title>
<script?type="text/javascript">
????function?message(){
confirm("請選擇,您現在的職業!");
}
function?aceger(){
alert("請先輸入姓名!");
}
function?bceger(){
alert("請先輸入密碼,再點擊確認!");
}
?function???cceger(){
?confirm("是否已輸入密碼?已輸入請按確認!");
?if(confirm()==true){
//這里該怎么寫,才能讓彈窗關閉
?}
?else{
?return?bceger();
?}
?}
</script>
<style?type="text/css">
*{margin:0;?padding:0;?font-size:14px;?color:#03F;}
#move{float:right;?margin-right:10px;margin-top:-10px;}
.pass{margin-top:5px;}/*div?id="move",做css樣式用#;div?classs="pass"做css樣式用.(英文的句號)*/
div:hover{color:#F00;}
</style>
</head>
<body>
??
???請選擇您的職業:<br?/>
????<form>
????????<select?name="changer"?onfocus="message()">
??????????????<option>教師</option>
??????????????<option>歌手</option>
??????????????<option>演員</option>
??????????????<option?selected="selected">工程師</option><!--selected=""selected默認選中-->
??????????????<option>律師</option>
????????</select>
?????????<div?id="move">
?????????姓名:<input?name="username"?type="text"?value="請輸入您的姓名"??onblur="aceger()"/><br?/>
?????????<div?class="pass">
?????????密碼:<input?name="password"?type="text"?value="請輸入密碼"?onmouseout="bceger()"??/>
??????????????????<input?name="button"?type="button"?value="確認"?onclick="cceger()"?/>??????????????????
??????????????????</div>
?????????</div>
?????????
????</form>
????
</body>
</html>代碼第19行該寫什么以達到點擊彈窗的確認按鈕后直接關閉彈窗
2016-09-07
function???cceger(){
???????? var confirm_ = confirm("是否已輸入密碼?已輸入請按確認!");
?????????if(confirm_ == true){???????????
????????????return;
????????}
?????????????else{
?????????????????return?bceger();
?????????????????}
???????? }
2016-09-12
function ? cceger(){
? ? ? ? ?var confirm_ = confirm("是否已輸入密碼?已輸入請按確認!");
? ? ? ? ?if(confirm_ == true){ ? ? ? ? ? ?
? ? ? ? ? ? confirm_.close();//這樣寫應該效果更明顯吧,其實我對“return”不太理解;這里寫“return”是返回到哪?
? ? ? ? }
? ? ? ? ? ? ?else{
? ? ? ? ? ? ? ? ?return bceger();
? ? ? ? ? ? ? ? ?}
? ? ? ? ?}
2016-09-11
你這樣寫相當于是調用了兩次confirm(),第二次沒帶參數,所以是一個空的彈窗。你可以看看confirm()函數的說明,如果點擊確定,就返回true,然后可以根據返回值進一步操作