我对函数一点也不擅长,并且学习 JavaScript,我需要一些帮助来学习我正在制作的示例之一。我有个问题。如何使下一个按钮仅在单击前一个按钮时才显示?(例如,如果不先点击 Google,就看不到 Yahoo 按钮)代码如下:
<html>
<head>
<script type="text/javascript">
function show_prompt()
{
var name=prompt("Your Name");
if (name!=null && name!="")
{
alert("Thanks for clicking! You will now be redirected to Google.com");
window.open("http://www.google.com/"};
}
</script>
<script type="text/javascript">
function show_alert()
{
alert("Thanks for clicking me! You are now going to Yahoo.com!");
window.open("http://www.yahoo.com");
}
</script>
<script type="text/javascript">
function show_alert1()
{
alert("Thanks for clicking. Have fun on facebook!");
window.open("http://www.facebook.com/");
}
</script>
</head>
<body>
<ul>
<li><input type="button" onclick="show_prompt()" value="Google" />
<li><input type="button" onclick="show_alert()" value="Yahoo" />
<li><input type="button" onclick="show_alert1()" value="Facebook" />
</ul>
</body>
</html>