Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iFrame not loading in Chrome unless window is resized

I have a web page as below which has Invoice numbers on the left side and when a user clicks on it, its details are loaded in iframe(id='invoiceFrame') which works fine in IE but in Chrome iframe is not loaded unless the window is resized

Google Chrome Version 42.0.2311.90 (Official Build) m (32-bit)

<script type="text/javascript">
   function getUrlParameter(URL, param){
    var paramTokens = URL.slice(URL.indexOf('?') + 1).split('&');
    for (var i = 0; i < paramTokens.length; i++) {
        var urlParams = paramTokens[i].split('=');
        if (urlParams[0].endsWith(param)) {
            return urlParams[1];
        }
    }
  } 
String.prototype.endsWith = function(pattern) {
    var d = this.length - pattern.length;
    return d >= 0 && this.lastIndexOf(pattern) === d;
};

 function resizeIframe(obj) {
    obj.style.height = obj.contentWindow.document.body.scrollHeight + 'px';
  }
    jQuery(document).ready(function () {
    jQuery("#mainFrame").hide();
   jQuery('#invoiceList tr:not(:first-child)').click(function(e){
    jQuery(".message").hide();
    e.preventDefault();
    var invoiceNumber =  jQuery(this).find("td").eq(0).text();
    var url = window.location.href;
   var lipId = getUrlParameter(url, 'lipId') 
  var invURL = '/CP/Invoice/InvoiceLineErrors.do?lipId='+lipId+'&invNum='+invoiceNumber;
   console.log('invoiceNumber '+invURL);
  jQuery("#mainFrame").show();
 document.getElementById("mainFrame").src =invURL;

});
   });
  </script>
       <style>
    h2.message{text-align: center; color: #FDFDFD; font-size: 1.1em; background: #708fc3; }  
    #invoiceList{ float: left; width: 15%; overflow-x:auto; }
    #invoiceFrame{float: right; width: 83.5%;   margin-bottom: 0em !important; }

        td error { color: red; font-size: 100%;} 
       tr.errortrue { color: #c33; font-size: 100%; font-weight: bold;} 
        table#lines th { background-color : grey;  color: white; width:100%}
       table {margin-bottom: 2em; border-bottom: 2px solid #ebebeb; empty-cells: show; border-collapse: collapse; }
       table#lines td { text-align: center; width:100%}

    iframe { float: left; width: 100%;  height =300px;
        }
       </style>
    </head>
    <body id='foo'>
<div class="ui-widget">
<center><h1> Invoice Error Details For ePacket P00000080235</h1></center>
  <div class="panel ui-widget-content" id="invoiceList">
 <h2 class="ui-widget-header ui-corner-top" style="cursor: pointer; font-size: 1.1em; "><span>Invoices</span></h2>
<table cellspacing='0' id='header' class="ui-widget">
   <tr>
        <th>Invoice Number</th>
         <th>Invoice Total</th>
  </tr>
  <tr class = 'errortrue'>
      <td>2015.04.08.001</td>
      <td>59.97</td>
  </tr>
</table> 
</div>
<!-- <div class='panel ui-widget-content' id="invoiceDetails">
<h2 class="ui-widget-header ui-corner-top" style="cursor: pointer; "><span>Select the Invoice Number on the left to view the error details</span></h2>-->
<h2 class='message'><span>Select the Invoice Number on the left to view the error details</span></h2>
<div class='panel ui-widget-content' id="invoiceFrame"><iframe src="" id="mainFrame" name="mainFrame" scrolling="no"  class='panel ui-widget-content' onload='javascript:resizeIframe(this);'></iframe>
    </div>

</div>
    </body>

Below is the content of the iframe

<script type="text/javascript">
jQuery('table#lines tr').each(function(){
  if (jQuery(this).html() == '') {
    jQuery(this).hide();
  }
});
  </script>
       <style>
       #invoice {padding: 0;}
       #invoiceErrors {overflow-x: auto;  overflow-y: auto;}
       tbody td{ border-top: 2px solid #efefef; border-bottom: 0px !important ;}
       td.error { text-align: left; color: #c33; font-size: 100%; background-image: none !important; padding-left : 0; border-bottom: 2px solid #0891F4;   white-space: nowrap;} 
       tr.errortrue { color: #c33; font-size: 100%; font-weight: bold;   white-space: nowrap;} 

       table {empty-cells: show; border-collapse: collapse; }
       table#lines td { text-align: left;}

       </style>
    </head>
<body id='invoice'>
 <div id="invoiceErrors">
  <div class='panel ui-widget-content' id="invoiceHeaders">
<h2 class="ui-widget-header ui-corner-top" style="cursor: pointer; font-family: Tahoma,Arial,sans-serif; font-size: 1.2em;"><span>Header Details</span></h2>
    <table class="ui-widget" id="headers">
                   <tr>
                        <th>Invoice Number</th>
                         <th>Matter Number</th>
                        <th>Invoice Total</th>
                        <th>Invoice Tax Total</th>
                        <th>Invoice Net Total</th>
                  </tr>

                     <tr class='errortrue'>
                        <td>2015.04.08.001</td>
                         <td>MAT-2</td>
                        <td>59.97</td>
                        <td>59.97</td>
                        <td>59.97</td>
                  </tr>
<tr ><td class = 'error'  style="padding-bottom: 4%;">

              Line : 1 Invoice tax total does not foot Reported = (0.0) Calculated = (1.0)<br/>

              Line : 1 Invoice Taxable Amount does not foot Reported = (59.97) Calculated = (58.97)<br/>

</td></tr>
  </table> 
</div>
<div class='panel ui-widget-content' id="invoiceLines">
<h2 class="ui-widget-header ui-corner-top" style="cursor: pointer; font-family: Tahoma,Arial,sans-serif; font-size: 1.2em;"><span>Invoice Line Items</span></h2>

 <table class="ui-widget" id="lines">
<tr>
<th>Line Item Number</th>
<th>Line Item Date</th>
<th>Unit Cost</th>
<th>Number of Units</th>
<th>Line Item Total</th>
</tr>

<tr class='errortrue'>
<td>1</td>
<td>20150402</td>
<td>19.99</td>
<td>3</td>
<td>59.97</td>
</tr>
<tr>
<td colspan="9" class='error' style="padding-bottom: 6%;">       
      Line : 1 MATH ERROR: ((19.99*3.0) - (0.0)) * (1.0) != 1.0 variance = 58.97<br/>
      Line : 1 MATH ERROR: (19.99*3.0) - (0.0) + (1.0) != 59.97 variance = 1.0<br/>
</td>
</tr>

</table>

</div>
 </div>
</body>

Can someone please help me with the iframe issue?

like image 920
RanPaul Avatar asked Nov 01 '22 06:11

RanPaul


1 Answers

Try adding position to iframe

iframe { float: left; width: 100%; height :300px; position:relative}
like image 50
Kishore Avatar answered Nov 12 '22 17:11

Kishore