onclick能否调用js函数中的变量
<script type="text/javascript" language="javascript">
var tiff,tiffemb,tiff_print;
if(document.getElementById) {
tiff=tiff + "<%=printnum%>";
tiffemb=tiffemb + "<%=printnum%>";
if(document.getElementById('tiffemb')) {
tiff=document.getElementById('tiffemb');
}
else if(document.getElementById('tiffobj')) {
tiff=document.getElementById('tiffobj');
}
}
else if(document.all) {
tiff=document.all.tiff;
}
</script>
<button onclick="tiff.Print(0)">Print</button>
如何让 onclick="tiff.Print(0)" 等于上面js中的tiff值,TKS
------解决方案--------------------
可以这样优化:
<script type="text/javascript" language="javascript">
var tiff;
var printNum="<%=printnum%>";
tiff=document.getElementById('tiffemb'+printNum) || document.getElementById('tiffobj'+printNum) || document.all['tiffobj'+printNum];
</script>