Image Sized Popup

[Total: 0    Average: 0/5]

This shows how to have a popup window show an image and be sized to hold that image.

Body Code:

<script>
var _obj=null;
var isIE=document.all?true:false;
var isNS6=navigator.userAgent.indexOf("Gecko")!=-1?true:false;

function showIt(_v)
{
  var _g="/js/pic"+_v+".gif";
  var _o="";
  if(isIE||isNS6)_obj=document.getElementById("pic"+_v);
  if(_obj)
  {
    _o+=" height="+(_obj.height);
    _o+=" width=" +(_obj.width);
  }
  window.open(_g,"",_o);
}
function showPreloadedImg()
{
  var _g=img4="http://www.js-examples.com/js/pic4.gif";
  var _o="";
  if(isIE||isNS6)_obj=document.getElementById("myimg4");
  if(_obj)
  {
    _o+=" height="+(_obj.height);
    _o+=" width=" +(_obj.width);
  }
  window.open(_g,"",_o);
}
</script>
<a href="javascript:showIt(1)"><img id=pic1 src='/js/pic1.gif' height=150 width=150></a>
<a href="javascript:showIt(2)"><img id=pic2 src='/js/pic2.gif' height=300 width=300></a>
<a href="javascript:showIt(3)"><img id=pic3 src='/js/pic3.gif' height=99 width=99></a>
<a href="javascript:showPreloadedImg()">Show preloaded imager #4</a>
<div id=div4 style="position:absolute;visibility:hidden">
<!-- put all your images that will pop up here so they can get sized -->
<img id=myimg4 src='http://www.js-examples.com/js/pic4.gif'>
</div>

Times Viewed: 0

Leave a Reply

Your email address will not be published. Required fields are marked *