日期:2014-05-16  浏览次数:20349 次

一个调用function的问题?
<script>
function   test1()
{
alert(1);
}

function   test2()
{
alert(2);
}
</script>
<input   type= "button "   onclick= "test1(); "   id= "test ">

在不能修改test1()和input的代码和不能对input进行操作,如document.getElementById( "test ").attachEvent( "onclick ", "test2 ")等的情况下
按下button执行test1()后,再执行test2()

------解决方案--------------------
<script>
function test1()
{
alert(1);
}

function test1()
{
alert(1);
alert(2);
}
</script>
<input type= "button " onclick= "test1(); " id= "test ">
------解决方案--------------------
<script>
function test1()
{
alert(1);
}

function test2()
{
alert(2);
}

document.onclick=function(){
if(event.srcElement.id== "test " && event.type== "click ") test2();
}
</script>

<input type= "button " onclick= "test1(); " id= "test ">
------解决方案--------------------
hb的算不算修改test1呢? :)
------解决方案--------------------
<script>
function test1()
{
alert(1);
}

function test2()
{
alert(2);
}
var t = test1;
test1 = function(){ t(); test2();}
</script>
<input type= "button " onclick= "test1(); " id= "test " value= "test ">
------解决方案--------------------
<script>
function test1()
{
alert(1);
}

function test2()
{
alert(2);
}

</script>
<div onclick= "if((event.srcElement||event.target).type== 'button ') test2(); ">
<input type= "button " onclick= "test1(); " id= "test " value= "test ">
<input type= "button " onclick= "test1(); " id= "test " value= "test ">
<input type= "button " onclick= "test1(); " id= "test " value= "test ">
<input type= "button " onclick= "test1(); " id= "test " value= "test ">
<input type= "button " onclick= "test1(); " id= "test " value= "test ">
<input type= "button " onclick= "test1(); " id= "test " value= "test ">


</div>