Home / code

Open in a small window

Writer: Christophe Wolfs
Published: 27 March 2008

This code is made to open a small window when clicked on a link.

All you need to do is, replace page.html with your url and fit the size to your needs (600 is the width, 400 the height).
You can also change the name of the page Name_of_the_new_page_no_spaces, but remember no_spaces!
0 means that we don't want scrolls, if you do want the user to be able to scroll, change it to 1.

<SCRIPT language="JavaScript">
<!-- start
//This code is made to open a small window when clicked on a link.
//Code provided by http://www.webmaster2020.com

//Normally you don't need to change anything here
//I always place this in the head section.
function linknew(location,picname,w,h,scroll) 
{
  var scrw=(screen.width/2)-(w/2);
  var scrh=(screen.height/2)-(h/2);
  window.open(location,picname,('toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars='+scroll+',resizable=0,copyhistory=0,left='+scrw+',top='+scrh+',width='+w+',height='+h));
}

// end -->
</SCRIPT>


The actual link:

<A HREF="javascript:void(0);" onClick="linknew('page.html','Name_of_the_new_page_no_spaces',600,400,0)">Click here</a>

 

TOP