Zoom images when you go to zoom button-JavaScript

 

<script language="JavaScript1.2">
var zoomfactor=0.05 //Enter factor (0.05=5%)
function zoomhelper()
{
if (parseInt(whatcache.style.width)>10&&parseInt(whatcache.style.height)>10&&parseInt(whatcache.style.width)<555)
{
whatcache.style.width=parseInt(whatcache.style.width)+parseInt(whatcache.style.width)*zoomfactor*prefix
whatcache.style.height=parseInt(whatcache.style.height)+parseInt(whatcache.style.height)*zoomfactor*prefix
}
}

function zoom(originalW, originalH, what, state)
{

if (!document.all&&!document.getElementById)
return
whatcache=eval("document.images."+what)
prefix=(state=="in")? 1 : -1

if (whatcache.style.width==""||state=="restore")
{
whatcache.style.width=originalW+"px"
whatcache.style.height=originalH+"px"

if (state=="restore")
return
}

else
{
zoomhelper()
}
beginzoom=setInterval("zoomhelper()",10)
}

function clearzoom()
{
if (window.beginzoom)
clearInterval(beginzoom)
}
</script>

 

CHANGE 500 to your image width, 375to image height, and "img.jpg" to your image's name

<a href="#" onmouseover="zoom(500,375,'myimage','in')" onmouseout="clearzoom()">Zoom In</a> | <a href="#" onmouseover="zoom(99,100,'myimage','restore')">Normal</a> | <a href="#" onmouseover="zoom(120,60,'myimage','out')" onmouseout="clearzoom()">Zoom Out</a>
<div style="position:relative;width:99;height:100"><div style="position:absolute">
<img name="myimage" src="img.jpg">

This code taken from web and works fine for me.so i put it here

No comments:

Post a Comment

Empowering the Future of API Management: Unveiling the Journey of WSO2 API Platform for Kubernetes (APK) Project and the Anticipated Alpha Release

  Introduction In the ever-evolving realm of API management, our journey embarked on the APK project eight months ago, and now, with great a...