Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/72.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中调用java脚本函数_Javascript_Html - Fatal编程技术网

Javascript 在HTML中调用java脚本函数

Javascript 在HTML中调用java脚本函数,javascript,html,Javascript,Html,我试图从java脚本打印html中的内容。我这样做了,但不起作用: <!DOCTYPE html> <html> <head> </head> <body> <p>I am trying to print <script>go();</script></p> <script> function go() { document.write("Hello World!"

我试图从java脚本打印html中的内容。我这样做了,但不起作用:

<!DOCTYPE html>
<html>
<head>

</head>
<body>
<p>I am trying to print <script>go();</script></p>



<script>

function go() {
 document.write("Hello World!");
}
</script>
</body>
</html>

我正在尝试打印go()

函数go(){ 写下“你好,世界!”; }
您正在发布的示例中尚未定义您的函数,因此调用go-effective不起任何作用,请更改脚本标记的顺序

<!DOCTYPE html>
<html>
<head>

<script>

function go() {
 document.write("Hello World!");
}
</script>

</head>
<body>
<p>I am trying to print <script>go();</script></p>



</body>
</html>

函数go(){
写下“你好,世界!”;
}
我正在尝试打印go()

非常感谢:),我找到问题了,可以解决了