Chrome中的plupload定位问题

发布于 2024-12-12 20:20:40 字数 1335 浏览 0 评论 0原文

我在通过 AJAX 动态加载的 plupload 中使用,而且这个表单有一个验证码图像。 我正在努力使 plupload 垫片正确定位。然后我找到了一个几乎适用于所有浏览器的解决方案,除了 Google Chrome。这是我的解决方案:

<span id="upl_container" style="position:relative;">
    <input type="button" id="my_button" value="Click me to upload something" />
</span>

在上传器设置中我设置:

        browse_button : 'my_button',
        container : 'upl_container',

现在这使得垫片绝对定位在相对父级中,其中父级(跨度)正是按钮的大小(我无法使用 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;
}

显然, left 属性太大了。

现在我不在乎这是否是一个错误,我只是想找到一些解决方法如何强制 plupload 的左侧为 0。我尝试添加一个 Javascript 代码,在 Init、Refresh 中将 left 设置为 0, PreInit回调plupload,但这并没有帮助,左侧无论如何都会跳到146px。

有没有办法强制 shim 的左侧为 0px?

(顺便说一句,我已将 Flash 设置为默认的 plupload 运行时,并回退到 HTML4 和 HTML5)。

I am using plupload in a from which is loaded dynamically through AJAX and also this form has a captcha image.
I was struggling to make plupload shim to position correctly. Then I found a solution which works in almost all browsers, except Google Chrome. Here is my solution:

<span id="upl_container" style="position:relative;">
    <input type="button" id="my_button" value="Click me to upload something" />
</span>

In uploader settings I set:

        browse_button : 'my_button',
        container : 'upl_container',

Now this makes the shim to be absolutely positioned in a relative parent, where the parent (span) is exactly the size of the button (I could not use div because it takes 100% width of its parent and then plupload has positioning problems on all browsers).

When I inspect the plupload shim settings in Firefox (where it is positioned correctly), I see the following:

element.style {
    background: none repeat scroll 0 0 transparent;
    height: 28px;
    left: 0;
    position: absolute;
    top: -4px;
    width: 78px;
    z-index: 99999;
}

but in Chrome it shows me:

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;
}

Obviously, the left property is much too big.

For now I don't care if it is a bug or not, I just want to find some workaround how to force left side of plupload to be 0. I tried to add a Javascript code which sets left to 0 in Init, Refresh, PreInit callbacks to plupload, but this does not help, the left side anyway jumps to 146px.

Is there any way to force the left side of shim to be 0px?

(BTW, I have set Flash to be the default plupload runtime with fallback to HTML4 and HTML5).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

半城柳色半声笛 2024-12-19 20:20:40

好吧,所以我使用了以下丑陋的代码:

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 runimes,并在 Chrome、Firefox、IE7、IE9 上进行了测试。垫片终于就位了。

Ok, so I went with the following ugly code:

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
})

And yay! it works for flash, htm5, htm4 runimes, tested all on Chrome, Firefox, IE7, IE9. The shim is in place, finally.

两个我 2024-12-19 20:20:40

我遇到了问题,因为垫片在动态加载和切换的内容上没有位于正确的位置。

$('#my_button').mouseenter(function() {
    uploader.refresh();
});

足以修复它。

I had problems with the shim not being in the right place on dynamically loaded and toggled content.

$('#my_button').mouseenter(function() {
    uploader.refresh();
});

Was sufficient to fix it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文