未捕获的ReferenceError:onload未定义函数

时间:2021-12-29 19:01:19

I am trying to use two different script tag in one html Page. 1st script tag I used the js file location o use the function and in other script tag I have written another function.

我试图在一个html页面中使用两个不同的脚本标记。第一个脚本标签我使用了js文件位置o使用该函数,而在其他脚本标签中我编写了另一个函数。

in 2nd script there is a function name CALCULATION which is called from the src file. but when I run the page it gives me Uncaught ReferenceError: ActiveProj is not defined at onload error

在第二个脚本中有一个函数名称CALCULATION,它从src文件中调用。但是当我运行页面时,它给了我Uncaught ReferenceError:在onload错误中没有定义ActiveProj

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

<script type="text/javascript" >
function ActiveProj() { 
var startdate = '05/11/2017';
var endate = '08/15/2017';
calculation(startdate,endate);
}
</script>
<body onload="ActiveProj();">

1 个解决方案

#1


4  

You just need to close the script tag by adding </script> after your javascript method, like this

您只需要在javascript方法之后添加 来关闭脚本标记,就像这样

 <script type="text/javascript" >
  function ActiveProj() { .... }
 </script> 

also put a closing tag on the other one, don't use a self closing tag.

还在另一个上放置了一个结束标记,不要使用自闭标记。

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

#1


4  

You just need to close the script tag by adding </script> after your javascript method, like this

您只需要在javascript方法之后添加 来关闭脚本标记,就像这样

 <script type="text/javascript" >
  function ActiveProj() { .... }
 </script> 

also put a closing tag on the other one, don't use a self closing tag.

还在另一个上放置了一个结束标记,不要使用自闭标记。

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