下面是02.html的内容:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="03.php"></script>
</head>
<body>
<script>
f();
</script>
</body>
</html>
下面是03.php的内容:
<script>
function f(){
alert("ABC");
}
</script>
运行02.html,得到空白页面,并没有弹出alert框。
在不改变03.php的文件后缀的前提下,如何调用这个文件中的js函数?
已经在外面<script src="03.php"></script>
用了<script>
标签
03.php中就应该只有js代码,不要有<script>
标签
03.php要写成:
function f(){
alert("ABC");
}
把03.php里的<script>标签删了就好