HanaBin
2019-08-07 15:54
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="Content-Type" content="text/html; charset=gbk"/>
<title>Insert title here</title>
<script type="text/javascript">
function button1()
{
var message1=confirm("please choose yes ro no?");
if(message1==true)
{
var message2=prompt("please enter your website","http://www.imooc.com/");
if(message2!=null)
{var message3=window.open('message2','width=400,height=500,menubar=no,toolbar=no')};
else
{document.write("bye1")};
}
else
{document.wriet("bye2!")};
}
</script>
</head>
<body>
<input type="button" value="打开" onclick="button1()" />
</body>
</html>
Eclipse好像不能识别JS代码,运行web项目之后也执行了Html语句,这个应该怎么解决?
答:if-else函数里面;号放在{}后面
---------------------------------------------------------------------------------------------------
以下是能成功运行的代码,我也不知道哪里错了,但是输入网址后点击确定,404,而且第一个if的else语句执行不了,点击取消则无任何反应,若想执行else应该怎么写?(目前只想到alert弹窗)
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="Content-Type" content="text/html; charset=gbk"/>
<title>Insert title here</title>
<script type="text/javascript">
function button1()
{
var message1=confirm("please choose yes ro no?");
if(message1==true)
{
var message2=prompt("please enter your website","http://www.imooc.com/");
if(message2!=null)
{var message3=window.open('message2','width=400,height=500,menubar=no,toolbar=no');}
else
{document.write("bye1");}
}
else
{document.wriet("bye2!");}
}
</script>
</head>
<body>
<input type="button" value="打开" onclick="button1()" />
</body>
</html>
没人吗?
JavaScript入门篇
739816 学习 · 9566 问题
相似问题