javascript函数里面的按钮不起作用?

时间:2013-06-14 05:03:43

标签: javascript html flash

这是我的javascript函数..

 <script>
    var count=0;

    function mafunct(flash){

    var path="a"+count+".swf";  

    var flash ='<OBJECT CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" CODEBASE="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" WIDTH="100%" HEIGHT="100%">';          
        flash+='<PARAM NAME="movie" VALUE='+path+' >';          
        flash+='<PARAM NAME="PLAY" VALUE="false">';  
        flash+='<PARAM NAME="LOOP" VALUE="false">';
        flash+='<PARAM NAME="QUALITY" VALUE="high">';
        flash+='<PARAM NAME="SCALE" VALUE="SHOWALL">';
        flash+='<EMBED NAME="testmovie" SRC="Menu.swf" WIDTH="100%" HEIGHT="100%"PLAY="false" LOOP="false" QUALITY="high" SCALE="SHOWALL"swLiveConnect="true"PLUGINSPAGE="http://www.macromedia.com/go/flashplayer/">';
        flash+='</EMBED>';
        flash+='</OBJECT>';  
This is a **button** inside the javascript function that show the bottom and out side of flash when click the first button

        flash+='<button onclick=mafunct()>next</button>';
        document.write(flash);
        alert(flash);
    count++;

    }
    </script>

这是我在html中的按钮代码

<button onclick=mafunct()>next</button>

当我点击此按钮时,第一个闪光灯将起作用,javascript功能中的按钮将显示,但按钮不起作用...

1 个答案:

答案 0 :(得分:4)

尽量避免使用document.write。尝试使用此代码创建按钮。

<style type = "text/css">
    .myButton
    {
        position:absolute;
        top:600px;
        left:300px;
        z-index:3000;
    }
</style>
var myButton = document.createElement("input");
myButton.type = 'button';
myButton.value = 'click Me';
myButton.className = 'myButton';
myButton.name = 'myButton';
myButton.onclick = function() { 
    mafunct();
};
document.body.appendChild(myButton);