<!-- define Magic Zoom -->
<a href="images/r1-red-3.jpg" class="MagicZoom" id="zoom" title="Cool bike!"><img src="images/r1-red-2.jpg"/></a> <br/>
<!-- stop some particular Magic Zoom (by ID) -->
<input type="button" onclick="MagicZoom.stop(document.getElementById('zoom'));" value="Stop zoom"/>
<!-- start some particular Magic Zoom (by ID) -->
<input type="button" onclick="MagicZoom.start(document.getElementById('zoom'));" value="Start zoom"/>
<!-- update zoom manually (first approach) -->
<script>
function blue(){
var zoom = document.getElementById('zoom'); //get the reference to our zoom object
// now apply new changes to our zoom (and only this zoom)
// new settings passed in the last parameter to update() function
// will only extend existing settings
MagicZoom.update(zoom, 'images/r1-blue-3.jpg', 'images/r1-blue-2.jpg', 'show-title: false');
}
</script>
<input type="button" onclick="blue();" value="Make it blue!"/>
<br/><br/>
<!-- update zoom manually (second approach) -->
<script>
function green(){
var zoom = document.getElementById('zoom'); //get the reference to our zoom object
zoom.href = 'images/r1-black-3.jpg'; //change the big image
zoom.rel = 'drag-mode: true; zoom-height: 170px'; // enable zoom drag mode
zoom.firstChild.src = 'images/r1-black-2.jpg'; //change the small image
// refresh ALL zooms on the page
MagicZoom.refresh();
}
</script>
<input type="button" onclick="green();" value="Make it draggable!"/>
<!-- track zooming position -->
<script>
function getCoords(){
var zoom = document.getElementById('zoom'); //get the reference to our zoom object
alert('Current zoom position is: x='+MagicZoom.getXY(zoom).x+', y='+MagicZoom.getXY(zoom).y);
}
</script>
<input type="button" onclick="getCoords();" value="Get coordinates (use drag mode)"/>