2016-10-31 6 views
-1

私は2種類のコードを持っています。 1はヌルで、もう1つはヌルではありません。ヌルとiframeが空であることを確認するにはどうすればよいですか?

私のコード:(==空)NOT NULL

<div class="col-xs-6"> 
    <iframe style="width:868px; height:550px;" id="FileReload" src="/Account/GetPDF?NUM=101"> 
     <html> 
      <head></head> 
      <body> 
       <pre style="word-wrap: break-word; white-space: pre-wrap;"></pre> 
      </body> 
     </html> 
    </iframe> 
</div> 

私のコード:(!=空)

<div class="col-xs-6"> 
    <iframe style="width:868px; height:550px;" id="FileReload" src="/Account/GetPDF?NUM=101"> 
     <html> 
      <body style="background-color: rgb(38,38,38); height: 100%; width: 100%; overflow: hidden; margin: 0"> 
      <embed width="100%" height="100%" name="plugin" id="plugin" src="http://localhost:49943/Account/GetPDF?NUM=101" type="application/pdf" internalinstanceid="74" title=""> 
      </body> 
     </html> 
    </iframe> 
</div> 

私のcontroler:

public ActionResult GetPDF(int NUM) 
{ 
    //.Select Database 
    //. 
    //. 
    if (reader.HasRows) 
    { 
     //Here passes null or not null. 
     PDF = ((byte[])reader["File"]); 
     return new FileContentResult(PDF, "application/pdf"); 
    } 
} 

null、iframeは白です。 nullでない場合、正常に動作します。 (私はレイアウトが白であるときはiframeを非表示にする。)

それは次のようになります(白のiframe)

enter image description here

をnullである場合には、白のiframeの幅と高さを表示する(もし==。 null - > iframeを非表示にする)

javascriptを使用してヌルかどうかを確認するには?

+0

「null」とはどういう意味ですか? –

+0

これらのiFramesはどれも空ではないので、より具体的にする必要がありますか? – adeneo

+0

@ScottMarcus null(空)の場合は、白いiframeを表示しないでください。 –

答えて

0

解決策が見つかりました!

$(function() { 
     $('#FileReload').load(function() {    
      if($.trim($(this).contents().find("body").find('embed').length) == 0) { 
      $(this).hide(); 
      } 
     }); 
    }); 
関連する問題