我想通过一个按钮调用JavaScript的一个函数,怎么不行呀

来源:百度知道 编辑:UC知道 时间:2024/06/06 20:57:45
我刚学JavaScript,怎么也弄不出来了,望各位帮小D一下
<!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=gb2312" />
<title>无标题文档</title>
<script language="javascript">
function promptfunc()
{
var answer=prompt("在这里");
}

</script>

</head>

<body >
<form>
<center>
<input type="button" value="点击这里" onclick="promptfunc()&

var answer=prompt("在这里");这里最后的分号错误
正确:

<!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=gb2312" />
<title>无标题文档</title>
<script language="javascript">
function promptfunc()
{
var answer=prompt("在这里");
}

</script>

</head>

<body >
<form>
<center>
<input type="button" value="点击这里" onclick="promptfunc()"/>