Open New Window And Show All Images

[Total: 0    Average: 0/5]

This shows how to have a page open up on a click that has all the images on it.

Body Code:

<img border=1 src="http://www.js-examples.com/js/pic1.gif">&nbsp;|&nbsp;
<img border=1 src="http://www.js-examples.com/js/pic2.gif"><BR>
<a href="javascript:makeNew()">click me</a>

<script>
var _np = null;
function makeNew() {
  var imageName;
  var _page  = "<head></head><body>";
  for (var imageNum=0;imageNum<document.images.length;imageNum++)
  {
      imageName = document.images[imageNum].src;
      _page += "Image #"+(imageNum+1)+" -&gt; ";
      _page += "<img border=1 src='"+imageName+"'><BR>";
  }
  _page += "</body>";
  _np = window.open("","np");
  _np.document.open();
  _np.document.write(_page);
  _np.document.close();
}
</script>

Times Viewed: 0

Leave a Reply

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