Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
 <h1 id="heading">?</h1>
   <h1 id="heading2">? </h1>
</body>
</html>
 
     
     var notYetLoaded = true;
     var heading1 =  document.getElementById("heading");
     var heading2 =  document.getElementById("heading2");
   function isPortrait(src, elem){
     var is  =  tryLoadImage(src);
    
      // use the "is" boolean here
     elem.innerHTML = "is it Portrait ? " + is;
   
     }
     function tryLoadImage(src) {
      var is = false;
     var img = new Image();
     img.src = src;
       var myWaiting = setInterval(function(){
         console.log("waiting");
         img.onload = function() {
        alert(img.width+"x"+img.height);
        if(img.height>img.width)
        {
           is= true;
        
        }  
         
        clearInterval(myWaiting);
           
         };
          
     }, 1000);
     
return true;
     }
    isPortrait("http://cdn.wonderfulengineering.com/wp-content/uploads/2014/07/Landscape-pictures-26-798x350.jpg", heading1);
    isPortrait("http://upload.wikimedia.org/wikipedia/commons/thumb/b/bd/Dts_news_bill_gates_wikipedia.JPG/440px-Dts_news_bill_gates_wikipedia.JPG", heading2);
Output 300px

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers