iframe onload函数没有被调用,如果在firefox中设置了src =“**。html”

时间:2018-04-15 22:16:58

标签: google-chrome firefox iframe angular-ui-grid

iframe onload函数没有被调用,如果在firefox中设置了src =“**。html”。删除后,文档无法在chrome中找到div。

<!doctype html>
<html ng-app="app">

<head>
  <meta charset="utf-8" />
  <script type="text/javascript">
    function on_load(iframe) {
      var element = document.getElementById('myuigrid');
      var scope = angular.element(element).scope();
      if (scope != null) {
        scope.setViewModel(myuigriddata);
      }
    }
  </script>
</head>
<!-- src="**.html" removed,document.getElementById('myuigrid') returned null; -->
<!-- if not, firefox can't call onload method -->

<body>
  <iframe style="display:none" onload="on_load(this)"></iframe>
  <div id="myuigrid" ng-if="!refresh" ui-grid="gridOptions">
  </div>
</body>

</html>

0 个答案:

没有答案