【问题标题】:iframe navigate to bookmark position not working in firefoxiframe 导航到书签位置在 Firefox 中不起作用
【发布时间】:2015-01-27 19:02:06
【问题描述】:

iframe 中有一个与 angularjs http 服务一起使用的页面。它会加载一些数据并为页面中的每个 li 放置 id。所以最终的 html 页面看起来像这样:

<li id="1000" ....>....</li>
<li id="1001" ....>....</li>
<li id="1002" ....>....</li>
<li id="1003" ....>....</li>
..
..
<li id="1020" ....>....</li>

这个页面在 iframe 中,所以我会像下面这样滚动父 iframe : ($scope.mid exits in li's id )

$q.all(promises)
....
})).then(function() {
                $("#divLoading").hide();
                var iframe = parent.document.getElementById("ConverstionsListFrame");

                iframe.location.replace(iframe.contentWindow.location + '#' + $scope.mid);
...}

所以上面的代码在 IExplorer 中运行良好,但在 firefox 中崩溃了,有时它工作,有时没有! 问题出在哪里 ?我认为也许 firefox 渲染队列与 IE 不同,这会导致 iframe 找不到锚 id,因为它还没有退出!请记录一下这个问题。

提前谢谢....

【问题讨论】:

    标签: javascript jquery angularjs firefox iframe


    【解决方案1】:

    这个指令将解决这个问题...

    .directive('onLastRepeat', function () {
            return function (scope, element, attrs) {
                if (scope.$last) setTimeout(function () {
    
                    var iframe = parent.document.getElementById("ConverstionsListFrame");
    
                    iframe.contentWindow.location.replace(iframe.contentWindow.location + '#' + scope.mid);
    
                }, 1);
            };
        })
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-06-16
      • 2012-11-27
      • 1970-01-01
      • 2015-02-15
      • 1970-01-01
      • 1970-01-01
      • 2012-05-31
      相关资源
      最近更新 更多