Number()的强制类型转换与parseInt()和parseFloat()方法的处理方式相似,只是它转换的是整个值,而不是部分值。parseInt()和parseFloat()方法只转换第一个无效字符之前的字符串。如“3.4.5”被转换成“3.4”,用Number()进行强制类型转换将返回NAN,如果字符串值能被完整地转换,Number()将判断是调用parseInt()还是parseFloat()。
<script type="text/javascript">
function showImage(href){
var type = ["","broken_head/","broken_branch/","loss_head/","loss_branch/"];
var hs = href.match(/.*_([1234]?)$/);
hs=hs==null?0:Number(hs[1]||"0");
$("<img>")
.attr("src",basePath+"process/jpdl/"+type[hs]+href+".png")
.dialog({
draggable:true,
modal:true,
width:"80%",
height:"auto",
resizable:true}
);
}
</script>
<a onclick="showImage('${fn:split(item.stringValue,'-')[0]}');">流程图</a>