mk3796432
2016-08-07 16:31
为甚,没反应
function openWindow()
{
var aa;
aa=prompt("确定打开吗?");
}
openWindow(); //你少了这个语句,是调用的
你只是定义了函数而没有调用,所以没反应 !!
function openWindow()
{
var aa;
aa=prompt("确定打开吗?");
}
openWindow(); //这个是调用方法是语句
<script type="text/javascript">
function openWindow(){
var aa;
aa=prompt("dfdfd")
}
openWindow();
</script>
//这个是有反应的 ,你可以试试
<!DOCTYPE html>
<html>
<head>
<title> new document </title>
<meta http-equiv="Content-Type" content="text/html; charset=gbk"/>
<script type="text/javascript">
function openWindow()
{
var aa;
aa=prompt("确定打开吗?");
}
openWindow();
</script>
</head>
</html>你定义了函数不调用,怎么会有反应。。。还有html基本的结构不能少吧。。。
JavaScript入门篇
741807 学习 · 9869 问题
相似问题