为什么上传文件控制器没有隐藏?
我正在创建一个上传网页。我将控制器的不透明度设置为 0 并将其位置设置为绝对位置并位于图像顶部。这样用户就不会看到丑陋的控制器,而是在单击图像时单击控制器。
一切正常,但是,当且仅当上传成功消息弹出时,丑陋的控制器才会显示。当您单击“确定”时,控制器会随着弹出消息消失。更奇怪的是,它并不是每次都显示。但它确实显示了一些时间,比如每两次计数一次。有什么想法吗?
我的代码:
$(document).ready(function() {
var left = $('#browseButton').offset().left;
var top = $('#browseButton').offset().top;
$("[id$='File1']").css('left', left);
$("[id$='File1']").css('top', top);
$("[id$='File1']").css('position', 'absolute');
$("[id$='File1']").css('z-index', '999');
});
<div align="center">Please choose attachment to upload
<input id="Text1" type="text" style="width: 400px" /><img src="../images/browse.jpg" id="browseButton" style="cursor:pointer;" width="24px" height="24px"/>
<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/images/upload-eng.gif" onclick="ImageButton1_Click" />
<input type=file id="File1" name=File1 runat="server" onchange="Text1.value=this.value" style="filter:alpha(opacity=0);width:24px;height:24px;" />
I'm creating an upload webpage. I set the controler's opacity=0 and set it's position to be abosolute and on top of an image. So that users won't see the ugly controler, but click the controler when they click the image.
Everything works fine, however, when and only when the upload succeeds message pop out, the ugly controler shows.And when you click OK, the controler dispears with the pop out message. What more weird is, it doesn't show every time. But it does shows some time like once every two counts. Any idea?
My code:
$(document).ready(function() {
var left = $('#browseButton').offset().left;
var top = $('#browseButton').offset().top;
$("[id$='File1']").css('left', left);
$("[id$='File1']").css('top', top);
$("[id$='File1']").css('position', 'absolute');
$("[id$='File1']").css('z-index', '999');
});
<div align="center">Please choose attachment to upload
<input id="Text1" type="text" style="width: 400px" /><img src="../images/browse.jpg" id="browseButton" style="cursor:pointer;" width="24px" height="24px"/>
<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/images/upload-eng.gif" onclick="ImageButton1_Click" />
<input type=file id="File1" name=File1 runat="server" onchange="Text1.value=this.value" style="filter:alpha(opacity=0);width:24px;height:24px;" />
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不确定为什么会发生这种情况,但您可以在上传控制器上另外设置
border:none
和background-color:transparent
,这样即使它确实随机显示,没什么可看的。Not sure why this is happening, but you could additionally set the
border:none
andbackground-color:transparent
on the upload controller so that even if it does randomly show up, there's nothing to see.您无法在上传按钮上使用
display:none
是否有原因?也只是一个建议,但文件上传工具之前已经编写过,也许这个会有所帮助(Uploadify)。它具有许多功能,包括使用 CTRL + 单击所有文件进行多文件上传以及对正在上传的文件进行排队。
Is there a reason why you cant use
display:none
on the upload button?Also just a recommendation, but file upload tools have been written before and maybe this one can be helpful (Uploadify). It has many features, including multi-file uploading using CTRL + clicking all files and queuing the files being uploaded.