
July 4th, 2008, 06:45 PM
|
 |
Contributing User
|
|
Join Date: Nov 2003
Location: UK
|
|
|
Make an area a hyperlink
you can javascript to check the position of the mouse on ur page when the user clicks the mouse and is within the area you want the link works.
here is an example:
Code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title></title>
<style type="text/css">
body
{
margin: 0px;
}
#divArea
{
background: #ff0000;
}
</style>
<script language="javascript">
<!--//
var xMin = 99;
var xMax = 301;
var yMin = 199;
var yMax = 401;
var posX = 0;
var posY = 0;
var IsArea = false;
var url = "http://forums.aspfree.com/";
var IE = document.all?true:false
if (!IE) document.captureEvents(Event.ONMOUSEDOWN)
document.onmousedown = checkMouseXY;
function checkMouseXY(e) {
if (IE) {
posX = event.clientX + document.body.scrollLeft
posY = event.clientY + document.body.scrollTop
}
else {
posX = e.pageX
posY = e.pageY
}
if (posX < 0){posX = 0};
if (posY < 0){posY = 0};
IsArea = false;
if (posX > xMin && posX < xMax) {
if (posY > yMin && posY < yMax) {
IsArea = true;
}
}
if (IsArea)
// the code below opens in new window
window.open(url);
// the code below opens in same window
//window.location.href = url;
}
//-->
</script>
</head>
<body>
<div id="divArea" onmouseover="this.style.cursor='pointer';" style="position:absolute; left:100; top:200; width:200; height:200; visibility:show;"> </div>
</body>
</html>
__________________
Hope this advise helps.
If so please show your appreciation by adding reputation points (click gauge image on top right of this post and score).
|