if后面的括号里可以直接写变量或者写true吗 求大神指点 若是写这两者 有什么结果?
check
check 2016-12-22 13:27:43
0
2
1306
<!DOCTYPE>
<html>
<head>
<meta http-equiv="Content-Type" 
content="text.html;charset=utf-8">
<title></title>
 <script>
 var addf=confirm("您好 想要进入该网站吗");
 if(true){
   document.write("欢迎访问本网站 很高兴为你服务");
   }
 else
 {
   alert("谢谢 忍痛拒绝");
 }
 </script>


check
check

reply all(2)
数据分析师

Can I write variables directly or write true in the brackets after if? Please give me some advice. What will be the result if I write these two? -PHP Chinese website Q&A - Can I write variables directly or write true in the brackets after if? Please give me some advice. What will be the consequences if I write these two? -PHP Chinese website Q&A

Please watch and learn.

迷茫

因为if后面的判断语句就是要判断执行if还是else后面的语句,如果你直接写if(true)的话,if后面永远是true,也就是说无论前面如何改变,都永远执行if里面的语句,不会执行else里面的语句。

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template