我试图在身体加载时调用javascript函数。 现在我在按钮上有一个函数调用,但当我添加相同的身体负载时,我无法调用该函数
HTML:
<body onload="bodyload();">
的javascript:
function bodyload(){
displayFireworks();
alert("working");
}
function displayFireworks() {
/*document.getElementById('auto_fire').innerHTML = '<a href="javascript:void" onClick="stopCount(); return false;" title="Stop" > <img src="image/button9.png" alt="Stop" width="200" height="50"> ';*/
createFirework(25,187,7,1,null,null,null,null,false,true);
t=setTimeout(function(){displayFireworks()},2000);
}
function doTimer() {
if (!poping) {
poping=1;
displayFireworks();
}
}
function stopCount() {
clearTimeout(t);
poping=0;
document.getElementById('auto_fire').innerHTML = '<a href="javascript:void" onClick="displayFireworks(); return false;" title="Auto Start" > <img src="image/button8.png" alt="Auto Start" width="200" height="50"> </a>';
}
焰火()
function Firework(oC,startX,startY,burstX,burstY,burstType,nRadius,nParticles,nCircles,allowRandom,obeyBoundaries) {
var self = this;
this.oID = 'fp'+(fc.gOID++); // may be unneeded
var p = '';
for (var i=0; i<arguments.length-1; i++) {
p += arguments[i]+',';
}
p += arguments[i];
writeDebug('firework('+p+')');
this.oC = oC;
this.o = fc.oFW.cloneNode(!fc.isIE?true:false);
this.particles = [];
this.vX = -1;
this.vY = -4;
this.x = startX;
this.y = startY;
this.allowRandom = allowRandom;
this.obeyBoundaries = obeyBoundaries;
this.frame = 0;
this.tween = [];
this.active = false;
如果我通过displayFireworks();
注释来调用bodyload,我可以使该功能正常工作,我可以获得警报框。但当我删除评论并致电displayFireworks();
时,我无法得到任何东西。我怎么能这样做?
答案 0 :(得分:0)
你没有一个名为“createFirework”的函数来调用你的烟火函数你不会关闭