Beautify the file upload interface (http://cms.bmw.net.cn) with transparent stacked Addition)

Source: Internet
Author: User
The transparent stacked addition method is used to implement the operation without IFRAME.
Place the file field on the clicked span and make it transparent.
In this way, you can see the custom span click area, but not the area where the file is browsed.
Click the Browse button, which does not violate any security mechanism.
Reference position of the original method. Http://www.script8.com/bbs/thread.asp? Tid = 6

<HTML>
<Head>
<Title> test HTML </title>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">
<Style>
Body
{
Font-size: 12px;
Cursor: default;
}
. Hand
{
Cursor: pointer;
Cursor: hand;
}
. Btnfade
{
Position: absolute;
Padding-top: 3px;
Font-family:;
}
. Btnreal
{
Position: absolute;
Width: 60px;
Overflow: hidden;
Filter: alpha (opacity = 0 );
-Moz-opacity: 0;
}
. Fileelement
{
Float: left;
Margin-Right: 6;
Padding-top: 3;
Color: darkgreen;
}
</Style>
</Head>
<Body onload = "setup ();">
<Script language = "JavaScript" type = "text/JavaScript">
// Use the reload tech cocould hide some control UI.
Function setup (){
$ ("Btnreal "). innerhtml = "<input onchange = \" AddFile (this ); \ "type = \" file \ "size = \" 1 \ "class = \" hand \ "hidefocus = \" True \ "/> ";
}

Function AddFile (File ){
// Create object append filename.
VaR filename, fileelement;
Filename = file. value. Replace (// \/g, "/"). Replace (/(. * \/) (. *)/, "$2 ");
File. style. Display = "NONE ";
Fileelement = Document. createelement ("nobr"); // just want to display the file.
Fileelement. classname = "fileelement ";
Fileelement. innerhtml = "□" + filename; // Add the filename.
Fileelement. innerhtml + = "<font style = color: red; font-weight: bold; onclick = \" $ (filelist ). removechild (this. parentnode); \ "class = hand>" + Unescape ("×") + "</font>"; // Add the delete button.
$ ("Filelist"). insertbefore (fileelement, $ ("btnfile "));
Setup ();
}

Function $ (element ){
Return typeof (element) = "object "? Element: Document. getelementbyid (element );
}
</SCRIPT>

<Div id = "filelist">
<Div id = "btnfile" onmouseover = "$ (btnfade ). style. textdecoration = underline; "onmouseout =" $ (btnfade ). style. textdecoration = none; "style =" color: Navy "> <! -- This Div just want to display a hand. -->
<Span id = "btnfade" class = "btnfade" style = "cursor: Pointer" >### add an attachment </span>
<Span id = "btnreal" class = "btnreal" onmouseover = "This. scrollleft = 100px"> </span>
</Div>
</Div>
</Body>
</Html>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.