<!DOCTYPE html>
<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 rec(){
var mychar=confirm("是否关注JS高级篇");
if(mychar=是){
document.write("关注JS高级篇");
}
else{
document.write("请开始学习JS入门篇");}
}
</head>
<body>
<p id="con">js进阶篇</p>
<form>
<input type="button" value="点击我" onClick="rec()"/>
</form>
</body>
</html>
俩个错:1.if(mychar=是)这样的写法是错误的,判断要用布尔值,而且要俩个等于,应该为if(mychar==true)
2.</script>这个闭合的你忘记写了,要写在</head>的上面
<!DOCTYPE html>
<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 rec(){
var mychar=confirm("是否关注JS高级篇");
if(mychar==true){
document.write("关注JS高级篇");
}
else{
document.write("请开始学习JS入门篇");}
}
</script>
</head>
<body>
<p id="con">js进阶篇</p>
<form>
<input type="button" value="点击我" onClick="rec()"/>
</form>
</body>
</html>
if语句的条件改成if(mychar)