<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title><script type="text/javascript">
window.onload=function(){
document.getElementById('test2').onclick=function(){
var i=document.getElementById('test');
var style=null;
if(document.defaultView&&document.defaultView.getComputedStyle){
style=document.defaultView.getComputedStyle(i);
}else{
style=i.currentStyle;
}
var width=style.width=='auto'?i.offsetWidth:style.width;
i.style.width=parseFloat(width)/2+'px';
}
}
</script>
</head><body>
<input type="text" id="test" />
<input type="button" id="test2" value='half'/>
</body>
</html>类似这样试试