XtremeEric
03-05-2009, 04:19 AM
First Post here.
I have this script that I found online. It works great.
The Problem I am having is I am now trying to hyperlink the image and it's not working.
what the script does is onmouseover it enlarges the image.
I would like when it does this to be able to click on the enlarged image as a link to another page.
<style>
#img_container
{
position:absolute;
display:none;
border:1px solid #f00;
background:#fff;
}
#large_img
{
width:200px;
height:290px;
}
</style>
<script>
function show(obj,obj1,obj2)
{
document.getElementById(obj).style.display="block";
document.getElementById(obj2).src=obj1.src;
var x_coords=findPosX(obj1);
var y_coords=findPosY(obj1);
document.getElementById(obj).style.left=x_coords;
document.getElementById(obj).style.top=y_coords;
}
function hide(id)
{
document.getElementById(id).style.display="none";
}
function findPosX(obj)
{
var curleft = 0;
if (document.getElementById || document.all)
{
while (obj.offsetParent)
{
curleft += obj.offsetLeft
obj = obj.offsetParent;
}
}
else if (document.layers)
curleft += obj.x;
return curleft;
}
function findPosY(obj)
{
var curtop = 0;
if (document.getElementById || document.all)
{
while (obj.offsetParent)
{
curtop += obj.offsetTop
obj = obj.offsetParent;
}
}
else if (document.layers)
curtop += obj.y;
return curtop;
}
</script>
Here is what the image code is
<img id="img1" width="117" height="180" src="../Images /David.jpg" border="2" onmouseover="show('img_container',this,'large_img');" alt="David">
Hope someone can help.
Thanks
I have this script that I found online. It works great.
The Problem I am having is I am now trying to hyperlink the image and it's not working.
what the script does is onmouseover it enlarges the image.
I would like when it does this to be able to click on the enlarged image as a link to another page.
<style>
#img_container
{
position:absolute;
display:none;
border:1px solid #f00;
background:#fff;
}
#large_img
{
width:200px;
height:290px;
}
</style>
<script>
function show(obj,obj1,obj2)
{
document.getElementById(obj).style.display="block";
document.getElementById(obj2).src=obj1.src;
var x_coords=findPosX(obj1);
var y_coords=findPosY(obj1);
document.getElementById(obj).style.left=x_coords;
document.getElementById(obj).style.top=y_coords;
}
function hide(id)
{
document.getElementById(id).style.display="none";
}
function findPosX(obj)
{
var curleft = 0;
if (document.getElementById || document.all)
{
while (obj.offsetParent)
{
curleft += obj.offsetLeft
obj = obj.offsetParent;
}
}
else if (document.layers)
curleft += obj.x;
return curleft;
}
function findPosY(obj)
{
var curtop = 0;
if (document.getElementById || document.all)
{
while (obj.offsetParent)
{
curtop += obj.offsetTop
obj = obj.offsetParent;
}
}
else if (document.layers)
curtop += obj.y;
return curtop;
}
</script>
Here is what the image code is
<img id="img1" width="117" height="180" src="../Images /David.jpg" border="2" onmouseover="show('img_container',this,'large_img');" alt="David">
Hope someone can help.
Thanks