<!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" xml:lang="zh-CN" lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>AttachEvent</title>
<style type="text/css">
<!--
body{font-size:12px;}
#txtFile{font-family:Arial, Helvetica, sans-serif;font-weight:bold;color:#6699FF;}
-->
</style>
<script language="javascript" type="text/javascript">
<!--
function FileBox(ID)
{
var faceObj = document.createElement("div");
faceObj.style.width = "66px";
faceObj.style.height = "24px";
faceObj.style.border = "1px solid #336699";
faceObj.style.overflow = "hidden";
var inputBox = document.createElement("input");
inputBox.type = "file";
inputBox.style.marginLeft = "-155px";
inputBox.style.marginTop = "-4px";
inputBox.style.height = "32px";
if(IsIE())
{
inputBox.style.filter = "alpha(opacity=0)";
}
else
{
inputBox.style.opacity = "0.0";
}
inputBox.id = ID;
inputBox.style.position = "relative";
inputBox.style.top = "-18px";
inputBox.style.left = "0px";
inputBox.style.zIndex = "500";
var inText = document.createElement("div");
inText.style.position = "relative";
inText.style.cursor = "default";
inText.style.fontFamily = "'微软雅黑','宋体'";
inText.style.fontSize = "12px";
inText.style.zIndex = "-1";
inText.style.left = "10px";
inText.style.top = "4px";
inText.innerHTML = "浏览...";
inputBox.onchange = function()
{
var txt = document.getElementById("txtFile");
txt.innerHTML = inputBox.value;
}
faceObj.appendChild(inText);
faceObj.appendChild(inputBox);
document.body.appendChild(faceObj);
}
function CreateBox(ID)
{
if(IsIE())
{
window.attachEvent("onload",function(){FileBox(ID);});
}
else
{
window.addEventListener("load",function(){FileBox(ID);},true);
}
}
function IsIE()
{
if(window.navigator.appName.indexOf("Microsoft") >= 0)
return true;
else
return false;
}
CreateBox("winid");
-->
</script>
</head>
<body>
<input type="hidden" name="xBox" id="xBox" />
<div id="txtFile"></div>
</body>
</html>