Hi there ,
I am trying to make Images on my site auto-ZoomIn on "mouseover" event , and auto-ZoomOut on "mouseout" event , but this is not working properly.
I hope some of you guys have tried such thing or seen such thing espescially on MAC , where Icons performs the same behaviour on mouseover, but i want to do it with Images .
It looks pretty simple , but becomes tough to combine Javascript with my PHP Code , where the Image Source is taken from the MySql Database Query.
Major Problems:
1-How to transfer Image Source from a PHP " $ " Variable to the Javascript Variable " var " ?
2- Should I make 6 <div>'s for 6 Images, in order to show their Zoomed HQ Image?
3-I don't want to use jQuery or other plugin files to make this happen for now.
Here is my Code :
I hope you understand the Code , if you find any Error regarding this Code or you think this Code needs improvements , then please guide me with my mistakes.
Please try this Code in your Browsers , i have tried it in IE8, Chrome 14(beta), Opera 11 and Firefox 6 , but all gave the same result.
Note : This Code is extracted from my site, it is not a complete page of my site but a small part of it , so it may have issues in the display.
I am trying to make Images on my site auto-ZoomIn on "mouseover" event , and auto-ZoomOut on "mouseout" event , but this is not working properly.
I hope some of you guys have tried such thing or seen such thing espescially on MAC , where Icons performs the same behaviour on mouseover, but i want to do it with Images .
It looks pretty simple , but becomes tough to combine Javascript with my PHP Code , where the Image Source is taken from the MySql Database Query.
Major Problems:
1-How to transfer Image Source from a PHP " $ " Variable to the Javascript Variable " var " ?
2- Should I make 6 <div>'s for 6 Images, in order to show their Zoomed HQ Image?
3-I don't want to use jQuery or other plugin files to make this happen for now.
Here is my Code :
Code:
<html> <head> <style> #productImg { width:600px; height:auto; position:relative; } #productImgBeta { width:auto; height:auto; position:absolute; z-index:-100000; visibility:hidden; } </style> <script language="javascript" type="text/javascript"> function imageZoomCancel() { document.getElementById("productImgBeta").style.zIndex = "-100000"; document.getElementById("productImgBeta").style.visibility = "hidden"; } function imageZoom() { document.getElementById("productImgBeta").style.zIndex = "100000"; document.getElementById("productImgBeta").style.visibility = "visible"; } function imgSrc() { //Not Sure what to put in here } </script> </head> <body> <div id="productImg"> <div id="productImgBeta"> <?php // $row['ProductImg'](0-11) are taken from MySQL Database // $row['ProductImg'](0-11) Contain the relative paths of the Images $LQImage1= $row['ProductImg']; $HQImage1= $row['ProductImg6']; $LQImage2= $row['ProductImg1']; $HQImage1= $row['ProductImg7']; $LQImage3= $row['ProductImg2']; $HQImage1= $row['ProductImg8']; $LQImage4= $row['ProductImg3']; $HQImage1= $row['ProductImg9']; $LQImage5= $row['ProductImg4']; $HQImage1= $row['ProductImg10']; $LQImage6= $row['ProductImg5']; $HQImage1= $row['ProductImg11']; ?> //Here the Zoomed In(High Quality) Image will be displayed <img align="left" width="500px" height="400px" src="imgSrc()" /> </div> //Here The Zoomed Out(Low Quality) Image will be displayed <img onmouseover="imageZoom()" onmouseout="imageZoomCancel()" width="150px" height="150px" src="<?php echo ($LQImage1); ?>" /> <img onmouseover="imageZoom() onmouseout="imageZoomCancel()" width="150px" height="150px" src="<?php echo ($LQImage2); ?>" /> <img onmouseover="imageZoom()" onmouseout="imageZoomCancel()" width="150px" height="150px" src="<?php echo ($LQImage3); ?>" /> <img onmouseover="imageZoom()" onmouseout="imageZoomCancel()" width="150px" height="150px" src="<?php echo ($LQImage4); ?>" /> <img onmouseover="imageZoom()" onmouseout="imageZoomCancel()" width="150px" height="150px" src="<?php echo ($LQImage5); ?>" /> <img onmouseover="imageZoom()" onmouseout="imageZoomCancel()" width="150px" height="150px" src="<?php echo ($LQImage6); ?>" /> </div> </body> </html>
I hope you understand the Code , if you find any Error regarding this Code or you think this Code needs improvements , then please guide me with my mistakes.
Please try this Code in your Browsers , i have tried it in IE8, Chrome 14(beta), Opera 11 and Firefox 6 , but all gave the same result.
Note : This Code is extracted from my site, it is not a complete page of my site but a small part of it , so it may have issues in the display.
Comment