Trafalgar D Law Trafalgar D Law - 10 days ago 5
HTML Question

Report not showing in IFrame

I have this code below for showing a report in 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
});


As I click the button only the dialogbox is showing.

Answer

You need to define var url = 'http://domain.com/path/to/the/report.html' It works now, see Snippet.

SNIPPET

$("#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>

Comments