如何在网页中多次调用一个js函数?

JavaScript014

如何在网页中多次调用一个js函数?,第1张

<script>

function seeBig(_this) {

document.getElementById("view_img").src=document.getElementById(_this).src

}

</script>

<body>

<table border="0" width="100%" cellspacing="3" cellpadding="3">

<tr>

<td align="center"><span class="spic">

<a href="javascript:void(0)" style="cursor:pointer">

<img border="0" id="a" src="http://img.baidu.com/img/iknow/avarta/110/r6s1g5.gif" width="110" height="150" onClick="seeBig('a')"></a></span></td>

<td align="center"><span class="spic">

<a href="javascript:void(0)" style="cursor:pointer">

<img border="0" id="b" src="http://img.baidu.com/img/logo-zhidao.gif" width="137" height="46" onClick="seeBig('b')"></a></span></td>

</tr>

<tr>

<td colspan="4" align="center" id="viewPic"><img id="view_img" border="0" src="pics/p1.jpg"></td>

</tr>

</table>

<table border="0" width="100%" cellspacing="3" cellpadding="3">

<tr>

<td align="center"><span class="spic">

<a href="javascript:void(0)" style="cursor:pointer">

<img src="http://static.youku.com/v1.0.0625/index/img/youkulogo-s.png" name="c" width="88" height="22" border="0" id="c" onClick="seeBig('c')"></a></span></td>

<td align="center"><span class="spic">

<a href="javascript:void(0)" style="cursor:pointer">

<img src="http://www.iciba.com/images/logos/logo_cd.jpg" name="d" width="190" height="72" border="0" id="d" onClick="seeBig('d')"></a></span></td>

</tr>

</table>

</body>

js里不要用document.all 这句在ie里还行,有些浏览器不兼容这句!

我这里也没有用 this 而是直接指明了id号,

<img id="b" onClick="seeBig('d')" src=......">

function multiplication(num) {

this.multiplication.x = num

function callback(num){

this.multiplication.x = this.multiplication.x * num

return callback

}

return callback

}

multiplication(2)(2)(8)

console.log(multiplication.x)

multiplication(4)(2)(8)

console.log(multiplication.x)

不知道这样算不算对?

加载一次就可以了,至于想调用里边的方法,只要加载完成,可以无限次调用。

调用方法<script src="xxx.js"></script>

加载多次,有可能会导致出错。