Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用javascript将src设置为另一个域的iframe打印到另一个域解决方案_Javascript_Html_Iframe_Printing - Fatal编程技术网

使用javascript将src设置为另一个域的iframe打印到另一个域解决方案

使用javascript将src设置为另一个域的iframe打印到另一个域解决方案,javascript,html,iframe,printing,Javascript,Html,Iframe,Printing,我们已经知道,您无法打印来自其他域的iframe内容。我试图通过在新窗口中打开iframe并在其中打印来解决此问题: <body> Other markup on the page that we don't want print here... <input type="button" value="Open window" onclick="openWin()" /> <iframe name="iframeID" src="http://ww

我们已经知道,您无法打印来自其他域的iframe内容。我试图通过在新窗口中打开iframe并在其中打印来解决此问题:

<body>
   Other markup on the page that we don't want print here...
   <input type="button" value="Open window" onclick="openWin()" />
   <iframe name="iframeID" src="http://www.sec.gov/Archives/edgar/data/1490630/000110465914022639/a14-8878_1ex10d1.htm" frameborder="0" style="overflow:hidden;height:100%;width:100%"></iframe>

   Other stuff that shouldn't print here...
</body>

有没有办法从url中获取内容以加载到弹出窗口并打印出来?

您是否在没有
popWindow.close()的情况下尝试过它?可能是
popWindow.print()
是异步的,因此调用会立即返回,
close()
会立即发生。我知道了。如果调用print(),它将在触发close()之前等待用户响应。所以print()没有被调用。
<script type="text/javascript">
  function openWin()
  {
    var popWindow=window.open('http://www.sec.gov/Archives/edgar/data/1490630/000110465914022639/a14-8878_1ex10d1.htm','','width=600,height=700');

    popWindow.document.close();
    popWindow.focus();
    popWindow.print();
    popWindow.close();

  }
</script>
var popWindow=window.open('','','width=600,height=700');