Javascript Pop Up Centered

Hi everyone - a quick, and probably easy question:

I am implementing a pop up window and need it to be centered. Found this code (below) seems to work good. I need to open it with an image rather than text link. Can anyone provide the correct syntax for this, if say the image was called ‘test.jpg’? Thanks!


<script type=“text/javascript”>
<!–
function popup(url)
{
var width = 300;
var height = 200;
var left = (screen.width - width)/2;
var top = (screen.height - height)/2;
var params = ‘width=’+width+‘, height=’+height;
params += ‘, top=’+top+‘, left=’+left;
params += ‘, directories=no’;
params += ‘, location=no’;
params += ‘, menubar=no’;
params += ‘, resizable=no’;
params += ‘, scrollbars=no’;
params += ‘, status=no’;
params += ‘, toolbar=no’;
newwin=window.open(url,‘windowname5’, params);
if (window.focus) {newwin.focus()}
return false;
}
// –>
</script>

<a href=“javascript: void(0)”
onclick=“popup(‘popup.html’)”>Centered popup window</a>

SlickAU, Range isn’t looking to open an image, but rather,

open it with an image rather than text link.

Your solution just opens an image, it doesn’t replace the text with an image.

A better way to approach this would be the following:


<a href="images/myImage.jpg" onclick="popup(this.href)">Open my image</a>

Good luck :eek:

Just put the image in rather the the text.


<a href="javascript: void(0)" onclick="popup('popup.html')">
<img src="test.jpg" alt="" /></a>