您现在的位置是:首页 > 电脑技术查询 > web开发

求教js调用js,该怎么解决

编辑:chaxungu时间:2022-10-02 23:21:06分类:web开发

求教js调用js
我有一个a.htm
<script language= "javascript " src= "1.js "> </script>
<body> 你好! <input onclick= "hellow() " type= "button "> </body>

有一个1.js
function hellow(){
alert( "hello! ");
}

还有一个2.js
function abc(){
document.write( "123 ");
}

现在我想在a.htm中运行1.js 然后在1.js中调用2.js。并且2.js执行后,不会让a.htm中的内容消失。请问怎么做啊?!
1.js是一个检测类的程序,2.js的内容是显示一些广告代码。

------解决方案--------------------
<script language= "javascript " src= "1.js "> </script>
<body> 你好! <input onclick= "hellow() " type= "button ">
<div id= "div1 "> &nbsp; </div> </body>

1.js
function hellow(){
alert( "hello! ");
abc()
}
2.js
function abc(){
document.getElementById( "div1 ").innerHTML= "123 ";
}