我正在定义.js文件的来源并尝试在同一标记中调用该文件中的函数,如下所示:


 < script type =“text / javascript”src =“jsFunctionTest.js”>
 testMethodCall();
< / script>



 .js文件只包含:
&#xA ;
 function testMethodCall(){
 window.alert(“Hello there”);
}



 这不起作用,我看不到警告。


但是,如果我将标记更改为两个标记,如下所示,那么它可以正常工作:

 
 < script type =“text / javascript”src =“jsFunctionTest.js”>< / script>
< script type =“text / javascript”> 
 testMethodCall();
< / script>



 这看起来非常混乱。有没有理由第一个不起作用?

答案 0 :(得分:9)
script
elements可以包含src
属性或内容,但不能同时包含两者。如果两者都有,则忽略内容(内容被视为“脚本文档”,而不是代码)。
答案 1 :(得分:0)
您无法在with AUF_KOPF (ERFASS_DAT,KOPF_SACH, AUF_NR) as (
select sysdate, 'EDI', 1 from dual union all
select sysdate, 'MODEM', 2 from dual union all
select sysdate, 'EDI1', 4 from dual union all
select sysdate, 'EDI3', 6 from dual
)
, ORDER_TOTALS (ORDER_NO) as (
select 1 from dual union all
select 1 from dual union all
select 1 from dual union all
select 2 from dual union all
select 2 from dual union all
select 2 from dual union all
select 4 from dual union all
select 4 from dual union all
select 6 from dual
)
Select To_Char(AUF_KOPF.ERFASS_DAT, 'IW') As "Week No",
Count(decode(AUF_KOPF.KOPF_SACH,'EDI', '1', 'MODEM','1')) As "Orders EDI or MODEM",
Count(decode(AUF_KOPF.KOPF_SACH,'EDI', null, 'MODEM',null, '1')) As "Orders but EDI or MODEM",
Count(AUF_KOPF.AUF_NR) As "total orders"
From AUF_KOPF AUF_KOPF
Inner Join ORDER_TOTALS On AUF_KOPF.AUF_NR = ORDER_TOTALS.ORDER_NO
Where trunc(AUF_KOPF.ERFASS_DAT,'yy') = date'2017-01-01'
Group By To_Char(AUF_KOPF.ERFASS_DAT, 'IW')
Order By "Week No"
个标记内注册外部文件并使用其中的内容。只允许任何一个。