jquery .show()不工作在Firefox [英] Jquery .show() not working in firefox
问题描述
情况:
我在一个弹出窗口(fancybox)中加载了一个带有aspx页面的iframe。在那个aspx页面中,我有一个带有onclick事件的按钮,它调用一个自定义函数,并在该函数中触发div上的.show()函数。这个div有一个style元素,其中包含:display:none ;.
这个在IE,safari,chrome中都有效。这甚至可以在firefox中工作,当我加载aspx页面独立。它不适用于fancybox-iframe弹出窗口中的Firefox。我没有得到任何JavaScript错误。即使显示:没有被从style属性中删除,但div不显示。
来自页面的html
< div class =popupWrapper>
..some elements
< div id =psharebuttonstyle =display:none;>
.. div的内容
< / div>
< / div>
javascript代码:
function dolinkedin(url,title,summary,source){
$(。smbutton)。addClass(buttonDisabled);
$(#linklinkedin)。removeClass(buttonDisabled);
$(#psharebutton)。show();
parent.sizeFancybox();
$ b $ p
$ b 弹出窗口被触发的按钮是一个锚点,它具有fancyboxiframe类。 Fancybox将自动生成显示弹出窗口的js代码。
我已经检查过这些主题:
我检查了我的html是否有效。
有什么想法?
解决方案 我有类似的问题,我的解决方案是做
$(#psharebutton ).css(display,inline-block);
而不是
$( #psharebutton)显示();
jqueryshow与将display style属性设置为block相同。我发现我需要内联块为Firefox和铬(我不需要这个IE浏览器)。我相信(但还没有确认),jquery足够聪明,知道什么是以前的显示值,并使用它,但在我的情况下,我开始与显示设置为无,所以没有以前的价值。
I have a problem with the jquery show function in firefox.
Situation:
I have loaded a iframe with an aspx page in a popup (fancybox). In that aspx page I have a button with an onclick event which calls a custom function and in that function it fires the .show() function on a div. This div has a style element which contains: display:none;.
This works in IE, safari, chrome. This even works in firefox when I load the aspx page standalone. It doesnt work in firefox in the fancybox-iframe popup. I get no javascript errors. Even the display:none is removed from the style attribute, but the div doesnt show up.
The html from the page
<div class="popupWrapper">
..some elements
<div id="psharebutton" style="display:none;">
..content of the div
</div>
</div>
The javascript code:
function dolinkedin(url, title, summary, source) {
$(".smbutton").addClass("buttonDisabled");
$("#linklinkedin").removeClass("buttonDisabled");
$("#psharebutton").show();
parent.sizeFancybox();
}
The button where the popup is triggered, is a anchor, which has the fancyboxiframe class. Fancybox will automaticly generate the js code for showing the popup.
I have checked these topics:
- Jquery Hide/Show not working in Firefox Only?
- Jquery hide/show not working in Firefox/Chrome
- Jquery .show() and .hide() or even .css({"display":"none"}); not working in firefox?
I have checked if my html is valid and it is.
Any idea?
BHD
解决方案 I had a similar problem and my solution was to do
$("#psharebutton").css("display", "inline-block");
instead of
$("#psharebutton").show();
A jquery "show" is identical to setting the display style attribute to "block". I found that I needed "inline-block" for firefox and chrome (I didn't need this for IE). I believe (but have not confirmed) that jquery is smart enough to know what the previous display value is and use that, but in my case I started out with display set to "none" so there was no previous value.
这篇关于jquery .show()不工作在Firefox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文