0

我不确定这是否可以做到。在我看来,我有这段代码:

  <div class="col3">
    <a id="training-launch-button" href='javascript:OpenScormModuleWindow(<%: Model.ScormModuleId %> , "<%: ViewBag.ScormModuleUrl %>", "<%:  ViewBag.title %>", <%:  ViewBag.WindowWidth %>, <%:  ViewBag.WindowHeight %>);' class="button" onclick ="Test()">Launch</a>
  </div>

 function OpenScormModuleWindow(scormModuleId, scormModuleUrl, title, width, height) {
   _scormModuleId = scormModuleId;
   InitializeUserScormModule();
   scormModuleWindow = window.open(scormModuleUrl, "title", "width=" + width + ", height=" + height + ", resizable = 1");
   scormModuleWindow.focus();
}

当我点击启动时,它会调用:

  function Test() {
      alert("try launch in new window");
      var newwindow = document.getElementsByClassName('targetblank');
      newwindow.target = '_blank';
      document.getElementById("iframe").src = "<%: ViewBag.ScormModuleUrl %>";
      document.getElementById("iframe").addEventListener('resize', function () {
          setWindowSize();
      });
  }

  function setWindowSize() {
      alert("in set winodw size");
      var myWidth = 0, myHeight = 0;
      if (typeof (window.outerWidth) == 'number')
      {
          myWidth = window.outerWidth;
          myHeight = window.outerHeight;
          alert(window.innerWidth + "  1  " + window.innerHeight + "  " + document.documentElement.clientWidth + "  " + document.documentElement.clientHeight);
          alert(myHeight + "   " + myWidth);
          $("#LaunchWidth").val(document.documentElement.clientWidth);
          $("#LaunchHeight").val(document.documentElement.clientHeight);
          updateSaveButtons();
      } 

然后我认为iframe:

  <iframe id="iframe" class="targetblank"></iframe>

它也永远不会在 setWindowSize 中收到警报 :( 该行document.getElementById("iframe").addEventListener('resize', function ()不起作用。

4

0 回答 0