Javascript Chrome中的多负载定位问题
我在一个通过AJAX动态加载的表单中使用plupload,并且这个表单有一个captcha图像。 我正在努力使plupload垫片正确定位。然后我找到了一个解决方案,除了谷歌Chrome,它几乎适用于所有浏览器。以下是我的解决方案:Javascript Chrome中的多负载定位问题,javascript,html,plupload,Javascript,Html,Plupload,我在一个通过AJAX动态加载的表单中使用plupload,并且这个表单有一个captcha图像。 我正在努力使plupload垫片正确定位。然后我找到了一个解决方案,除了谷歌Chrome,它几乎适用于所有浏览器。以下是我的解决方案: <span id="upl_container" style="position:relative;"> <input type="button" id="my_button" value="Click me to upload somet
<span id="upl_container" style="position:relative;">
<input type="button" id="my_button" value="Click me to upload something" />
</span>
现在,这使得垫片绝对定位在相对的父级中,父级(span)正好是按钮的大小(我不能使用div,因为它占用父级的100%宽度,然后plupload在所有浏览器上都有定位问题)
当我在Firefox中检查plupload shim设置时(它的位置正确),我看到了以下内容:
element.style {
background: none repeat scroll 0 0 transparent;
height: 28px;
left: 0;
position: absolute;
top: -4px;
width: 78px;
z-index: 99999;
}
但在Chrome中,它向我展示了:
element.style {
position: absolute;
background: transparent;
z-index: 99999;
top: 0px;
left: 146px;
width: 70px;
height: 23px;
background-position: initial initial;
background-repeat: initial initial;
}
显然,左属性太大了
现在我不在乎它是否是一个bug,我只想找到一些解决方法,如何强制plupload的左侧为0。我尝试添加一个Javascript代码,将Init、Refresh、PreInit回调中的left设置为0到plupload,但这没有帮助,左侧还是跳到146px
有没有办法强制垫片左侧为0px?
(顺便说一句,我已经将Flash设置为默认的plupload运行时,回退到HTML4和HTML5)。好的,所以我使用了以下难看的代码:
uploader.bind('Refresh', function(up) {
$('#'+up.settings.container + ' > div').css('left',0);
$('#'+up.settings.container + ' > div').css('top',0);
$('#'+up.settings.container + ' > div').css('width','100%');
$('#'+up.settings.container + ' > div').css('height','100%');
$('#'+up.settings.container + ' > form').css('left',0);
$('#'+up.settings.container + ' > form').css('top',0);
$('#'+up.settings.container + ' > form').css('width','100%');
$('#'+up.settings.container + ' > form').css('height','100%');
$('#'+up.settings.container + ' > div').children().css('left',0);
$('#'+up.settings.container + ' > div').children().css('top',0);
$('#'+up.settings.container + ' > div').children().css('width','100%');
$('#'+up.settings.container + ' > div').children().css('height','100%');
$('#'+up.settings.container + ' > div').children().css('font-size','20px');// default is 999px, which breaks everything in firefox
})
耶!它适用于flash、htm5、htm4运行时,全部在Chrome、Firefox、IE7、IE9上测试。垫片终于就位了。在动态加载和切换内容时,我遇到了垫片不在正确位置的问题
$('#my_button').mouseenter(function() {
uploader.refresh();
});
已经足够解决了。你可以链接这些内容,这样你就不必每次都重新选择它们,比如
$('.''.'设置'.''容器+'>div').children().css('height','100%').css('font-size','20px')
不幸的是,对于我来说,使用1.5.5版本,它不起作用,尽管它应该起作用(在plupload论坛上阅读)。我调用了destroy(),然后再次重新初始化该对象。。。不是最好的解决方案,也不是最节省资源的解决方案!
$('#my_button').mouseenter(function() {
uploader.refresh();
});