| : | Javascript Index | : | PHP | : | MySQL | : |
| : | Source | : | : | Explanation | : | : | Example | : | : | Todo | : | : | Feedback | : |
Simple but effective tool to extract the coordinates of an image that you want to use for making an HTML imagemap (usemap)
Added: 2006-09-19 22:18:38
download javascript source code only
download full working script (recommended)
/******
* You may use and/or modify this script as long as you:
* 1. Keep my name & webpage mentioned
* 2. Don't use it for commercial purposes
*
* If you want to use this script without complying to the rules above, please contact me first at: marty@excudo.net
*
* Please be aware that this is only the core source-code of a full script and that it may not work (for you) without the rest.
* The full script can be downloaded from my website. A working example is provided there as well.
*
* Author: Martijn Korse
* Website: http://devshed.excudo.net
*
* Date: 2006-09-19 22:18:38
***/
if (!document.all)
document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = getMouseXY;
xCoord = 0;
yCoord = 0;
function getMouseXY(e)
{
if (document.all)
{
// coordinates in IE
xCoord = event.clientX + document.body.scrollLeft;
yCoord = event.clientY + document.body.scrollTop;
}
else
{
// otherwise
xCoord = e.pageX;
yCoord = e.pageY;
}
if (xCoord < 0)
xCoord = 0;
if (yCoord < 0)
yCoord = 0;
document.getElementById('showX').innerHTML = xCoord;
document.getElementById('showY').innerHTML = yCoord;
}
function recordCoords()
{
output = document.getElementById('gatherCoords').value;
if (output.length > 0)
document.getElementById('gatherCoords').value = output+', '+xCoord+','+yCoord;
else
document.getElementById('gatherCoords').value = xCoord+','+yCoord;
}
function loadImg()
{
document.getElementById('srcImg').src = document.getElementById('loadImg').value;
}
download javascript source code only
download full working script (recommended)