Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/423.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简单打印传递参数_Javascript - Fatal编程技术网

Javascript简单打印传递参数

Javascript简单打印传递参数,javascript,Javascript,我希望在下面的代码中打印传递参数的值。但它会打印[对象事件] 我不熟悉演示文稿开发。我错过了什么 <body onload("initialize('-33.873651000000000000','151.206889600000070000')")> <!DOCTYPE html> <html> <head> <script src=""></script> <script> function

我希望在下面的代码中打印传递参数的值。但它会打印[对象事件]

我不熟悉演示文稿开发。我错过了什么

 <body onload("initialize('-33.873651000000000000','151.206889600000070000')")>

 <!DOCTYPE html>
 <html>
 <head>
 <script src=""></script>

 <script>
function initialize(longitude,latitude){
 alert(longitude)
 }
</script>

body标记需要放在html标记中。也可以使用onload=

 <!DOCTYPE html>
 <html>
 <head>
 <script src=""></script>

 <script>
function initialize(longitude,latitude){
 alert(longitude)
 }
</script>
   </head>

   <body onload= "initialize('-33.873651000000000000','151.206889600000070000')")>
   </body>
</html>

修复Html代码中的标记顺序: 基本HTML结构如下所示:

<!DOCTYPE html>
<html>
    <head>...</head>
    <body>...</body>
</html>
所以你会有这个:

<html>
  <head>
    <script type="text/javascript">
       function initialize(longitude, latitude){
         alert(longitude);
       }
    </script>
  </head>

  <body onload = "javascript:initialize('-33.87651000000000000','151.206889600000070000');">
  </body>
<html>
<html>
  <head>
    <script type="text/javascript">
       function initialize(longitude, latitude){
         alert(longitude);
       }
    </script>
  </head>

  <body onload = "javascript:initialize('-33.87651000000000000','151.206889600000070000');">
  </body>
<html>