Copy codeThe Code is as follows:
Window ["MzBrowser"] = {};
(Function ()
{
If (MzBrowser. platform) return;
Var ua = window. navigator. userAgent;
MzBrowser. platform = window. navigator. platform;
MzBrowser. firefox = ua. indexOf ("Firefox")> 0;
MzBrowser. opera = typeof (window. opera) = "object ";
MzBrowser. ie =! MzBrowser. opera & ua. indexOf ("MSIE")> 0;
MzBrowser. mozilla = window. navigator. product = "Gecko ";
MzBrowser. netscape = window. navigator. vendor = "Netscape ";
MzBrowser. safari = ua. indexOf ("Safari")>-1;
If (MzBrowser. firefox) var re =/Firefox (\ s | \/) (\ d + (\. \ d + )?) /;
Else if (MzBrowser. ie) var re =/MSIE () (\ d + (\. \ d + )?) /;
Else if (MzBrowser. opera) var re =/Opera (\ s | \/) (\ d + (\. \ d + )?) /;
Else if (MzBrowser. netscape) var re =/Netscape (\ s | \/) (\ d + (\. \ d + )?) /;
Else if (MzBrowser. safari) var re =/Version (\/) (\ d + (\. \ d + )?) /;
Else if (MzBrowser. mozilla) var re =/rv (\ :) (\ d + (\. \ d + )?) /;
If ("undefined "! = Typeof (re) & re. test (ua ))
MzBrowser. version = parseFloat (RegExp. $2 );
}
)();
Function upLoadKey (e, object)
{
If (document. all )? True: false)
{
Window. event. keyCode = 9? (Window. event. returnValue = true): (window. event. returnValue = false );
}
Else
{
If (object. value = "" & typeof e. which = "number") e. preventDefault ();
If (object. value! = "") Object. blur ();
}
}
Function version (object)
{
If (MzBrowser. firefox & MzBrowser. version = 2) object. blur ();
}
Function clearValue (id)
{
Var up = (typeof id = "string ")? Document. getElementById (id): id;
If (typeof up! = "Object") return null;
Var tt = document. createElement ("span ");
Tt. id = "_ tt __";
Up. parentNode. insertBefore (tt, up );
Var tf = document. createElement ("form ");
Tf. appendChild (up );
Document. getElementsByTagName ("body") [0]. appendChild (tf );
Tf. reset ();
Tt. parentNode. insertBefore (up, tt );
Tt. parentNode. removeChild (tt );
Tt = null;
Tf. parentNode. removeChild (tf );
}
// Page code
Copy codeThe Code is as follows:
<Html>
<Head>
<Script language = "javascript" src = "upLoad. js"> </script>
</Head>
<Body>
<Input name = "textfield3" type = "file" class = "input" id = "textfield3" size = "30" value = "" ondrag = "return false; "oncut =" return false; "onkeydown =" upLoadKey (event, this); "onpaste =" return false; "onmousedown =" document. oncontextmenu = function () {return false;} "onmouseout =" document. oncontextmenu = function () {return true ;}; version (this ); "tabIndex =-1/> <input type =" button "id =" clear "value =" empty "onclick =" clearValue ('textfield3'); "/>
</Body>
</Html>