【问题标题】:cannot scroll iframe content on Firefox无法在 Firefox 上滚动 iframe 内容
【发布时间】:2011-09-13 19:26:21
【问题描述】:

我在我的页面上使用了一个模态窗口,它实际上有一个在 iframe 中调用的框架集页面。动态附加模态窗口的代码是这样的;

$("#TB_window").append("<iframe frameborder='0' hspace='0' src='"+urlNoQuery[0]+"' id='TB_iframeContent' name='TB_iframeContent"+Math.round(Math.random()*1000)+"' onload='tb_showIframe()' style='width:"+(ajaxContentW + 29)+"px;height:"+(ajaxContentH + 17)+"px;' > </iframe>");

生成的 HTML 看起来像;

<div id="TB_window" style="margin-left: -500px; width: 1001px; display: block;">
<iframe frameborder="0" style="width:1000px;height:581px;" onload="tb_showIframe()" name="TB_iframeContent805" id="TB_iframeContent" src="framesetPg.html" hspace="0"> </iframe></div>
</div>

现在,在 IE 上,我可以滚动浏览主页面以及内部框架,但在 Firefox 上,我无法完全滚动浏览主框架集页面..

还要总结一下这个问题,这应该有助于确定问题所在; 如果我隐藏 Windows 任务栏以便为 Firefox 窗口提供更多垂直空间,我可以看到完整的框架集页面......所以类似于视口或基于显示高度。反向也是如此,即如果我向上拖动任务栏,以便 FF 可用的空间更少,它只会显示那么多内容,而我无法滚动其余内容..

请帮助我。谢谢。

【问题讨论】:

  • 你在使用 jquery 吗?如果是,哪个插件?
  • 是的...我正在使用Thickbox插件

标签: javascript jquery html firefox iframe


【解决方案1】:

添加这个

$("body").css("overflow", "auto");
$("html").css("overflow", "auto");

thickbox.js 中的tb_show 函数的顶部,此处未压缩是示例 这就是它的样子

function tb_show(caption, url, imageGroup) {//function called when the user clicks on a thickbox link

    try {
        if (typeof document.body.style.maxHeight

改成这个

function tb_show(caption, url, imageGroup) {//function called when the user clicks on a thickbox link
    $("body").css("overflow", "auto");
    $("html").css("overflow", "auto");
    try {
        if (typeof document.body.style.maxHeight

剩下的就放心了如果不工作,发到jsfiddle让我看看

【讨论】:

  • 非常感谢...我确实尝试过...它确实在 Firefox 中显示了外部滚动条,但是当我们向下滚动时,它只是将滚动条向下移动,而没有真正滚动浏览主框架集页面。 ..出于正当的原因,很抱歉我可以与您分享整个代码..
  • @hmthr man could 你只是尝试另一个模态,thickbox 是一个长期死的模态插件尝试simplemodalfancybox,等等,如果你使用任何其他 js 库,插件...确保thickbox没有冲突的问题
猜你喜欢
  • 2013-08-24
  • 1970-01-01
  • 1970-01-01
  • 2011-02-22
  • 1970-01-01
  • 1970-01-01
  • 2014-09-04
  • 1970-01-01
  • 2023-03-23
相关资源
最近更新 更多