大家好,我有更多问题。我现在正在处理函数和事件,这是我到目前为止所做的..
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Personal Information</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="js_styles.css" type="text/css" />
<script type="text/javascript">
//<![CDATA[
function printPeronalinfo( "name,age,hobbies,favorite movies") {
document.write("<p>" + name +"</p>");
document.write("<p>" + age +"</p>");
document.write("<p>" + hobbies + "</p>");
document.write("<p>" + favorite video + "</p>");
}
//]]>
</script>
</head>
<body>
<script type="text/javascript">
/ * <![CDATA[ */
printPeronalinfo( "age,age,hobbies,favorite movies")
var return_value = return_message();
document.write(return_value);
/*]]> */
</script>
</body>
</html>
现在我的问题是我知道我做错了,因为它没有出现在网页上。我想读一下我的名字,年龄,爱好,喜欢的电影。现在我要重复我的头部到身体,但不是单词名称,我会把我的名字放在那里或我使用if或其他(但我很确定这是按钮)。我也知道我可以使用数组,但我不知道这是否有用。
答案 0 :(得分:2)
从函数参数中删除引号:
function printPeronalinfo( name,age,hobbies,favoritemovies)
然后调用这个函数:
printPeronalinfo( "name","age","hobbies","favorite movies")
答案 1 :(得分:2)
你有几个错误..
function printPeronalinfo( "name,age,hobbies,favorite movies") {
/* ^ no quotes here, ^ invalid variable name */
// should be: function printPeronalinfo(name, age, hobbies, favorite_movies) {
document.write("<p>" + name +"</p>");
document.write("<p>" + age +"</p>");
document.write("<p>" + hobbies + "</p>");
document.write("<p>" + favorite video + "</p>");
/* ^ undefined variable, isn't defined in your function */
// should be: document.write("<p>" + favorite_movies + "</p>");
}
...
printPeronalinfo( "age,age,hobbies,favorite movies");
/* ^ incorrect passing of data */
// should be: printPeronalinfo("name", "age", "hobbies", "favorite movies");
您还应该知道您的功能名称将“个人”拼错为“Peronal”。
更新:在您的第二个<script>
区块中,您的评论区块标记不正确:/ *
不应有空格。这是正确的:/*