Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/470.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 为什么在我的基本html(带js文件)页面上看不到警报?_Javascript_Html - Fatal编程技术网

Javascript 为什么在我的基本html(带js文件)页面上看不到警报?

Javascript 为什么在我的基本html(带js文件)页面上看不到警报?,javascript,html,Javascript,Html,刚开始学习网络开发 我创建了两个文件 -html文件 -js文件 我编写的js文件代码: function func1() { alert("alert message"); //document.writeln("document write line"); //console.log("this is log message"); } html文件代码: <html> <head> <script type="text/

刚开始学习网络开发

我创建了两个文件 -html文件 -js文件

我编写的js文件代码:

function func1()
{
    alert("alert message");

    //document.writeln("document write line");

    //console.log("this is log message");

 }
html文件代码:

<html>
<head>
    <script type="text/javascript" src="basicFile.js"/>
</head>

<body>
    <script>
        func1();
    </script>
</body>
为什么警报不会弹出? 此外,doc.writeln不起作用


当我直接在html上编写js func1时,它的工作很好,因为您需要以不同的方式关闭脚本标记。做

<script type="text/javascript" src="test.js"></script>
而不是

<script type="text/javascript" src="test.js" />

谢谢现在就开始工作