在不同浏览器中获取File Input的路径
<!doctype html public "-//w3c//dtd html 4.01//en" "http://www.w3.org/tr/html4/strict.dtd">
<html>
<head>
<title>File Input</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<style>
body{font-size:13px;}
.box{border:1px solid #eee;background:#ffe;padding:10px 30px;margin:10px;}
dt{font-weight:bold;}
dt,img,textarea{margin:8px 0;}
em{color:#f00; font-style:normal;}
span{color:#999;}
.ft{color:#999;font-size:11px;text-align:right}
</style>
</head>
<body>
<h2>在不同浏览器中获取File Input的value</h2>
<div name="foo" id="foo" size="60" />
??? <input type="button" value="Show Value" onClick="alert(document.getElementById('foo').value)" />
??? <input type="button" value="Show Value in FF3" onClick="alert(getValueFF('foo'))" />
??? <input type="button" value="Show Value in IE8" onClick="alert(getValueIE8('foo'))" />
</div>
<div target="_blank" >https://bugzilla.mozilla.org/show_bug.cgi?id=143220</a></span>
??? </p>
</div>
<div target="_blank" >https://bugzilla.mozilla.org/attachment.cgi?id=328849</a></p>
</div>
<script language="JavaScript">
???
??? function getValueFF(id){
??????? var ip = document.getElementById(id);
??????? if (ip.files) {
??????????? //ffx3 - try to have access to full path
??????????? try {
??????????????? netscape.security.PrivilegeManager.enablePrivilege( 'UniversalFileRead' )
??????????? }
??????????? catch (err) {
??????????????? //need to set signed.applets.codebase_principal_support to true
??????????? }
??????? };
??????? return ip.value;
??? }
??? function getValueIE8(id){
??????? var ip = document.getElementById(id);
??????? ip.select();
??????? return document.selection.createRange().text;
??? }
</script>
</body>
</html>