javascript - 报告未显示在 IFrame 中

标签 javascript jquery html iframe

下面的代码用于在 IFrame 中显示报告

HTML

<div id="dialogGenerateGL">
<div>
    <iframe id="frmGLs" style="width: 800px; height: 600px; border: 2px solid black; margin: 10px auto;">
    </iframe>
</div>

JS

$("#Button").click(function(){
 var url = url;
 $("#dialogGenerateGL").dialog("open");
 $("#frmGLs").attr('src', url);
});


$("#dialogGenerateGL").dialog({
    autoOpen: false,
    height: 'auto',
    width: 'auto',
    modal: true
 });

当我单击按钮时,仅显示对话框。

最佳答案

您需要定义var url = 'http://domain.com/path/to/the/report.html'它现在可以工作,请参阅代码片段。

片段

$("#btn1").click(function() {
  var url = 'http://example.com/';
  $("#dialogGenerateGL").dialog("open");
  $("#frmGLs").attr('src', url);
});


$("#dialogGenerateGL").dialog({
  autoOpen: false,
  height: 'auto',
  width: 'auto',
  modal: true
});
<link href='https://cdn.jsdelivr.net/jquery.ui/1.11.4/jquery-ui.min.css' rel='stylesheet'>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>

<button id='btn1'>Dialog</button>
<div id="dialogGenerateGL">
  <div>
    <iframe id="frmGLs" style="width: 800px; height: 600px; border: 2px solid black; margin: 10px auto;">
    </iframe>
  </div>

关于javascript - 报告未显示在 IFrame 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40777229/

相关文章:

jquery - 如何在 Laravel 中将数组从 Controller 发送到 JavaScript?

javascript - 如何让代码在调用带有返回值的异步调用(如 Ajax)时等待

html - 添加侧边栏而不改变主要内容的对齐方式

html - 将绝对定位的 child 与过度隐藏的相对 parent 对齐

JavaScript 循环以容纳从 Webhook 接收的已过滤对象数组

javascript - 为什么单击嵌套元素不会通过单击绑定(bind)冒泡到它的父元素?

jquery - 如何在数组中使用 jQuery mouseover?

html - MVC(五)根据另一个填充下拉列表

javascript - 使用 JavaScript 动态生成 HTML 元素列表的最佳方法是什么?

javascript - jQuery 可扩展菜单