HTML, JavaScript And CSS Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingHTML, JavaScript And CSS Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old July 3rd, 2008, 10:16 AM
cornall cornall is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2008
Posts: 267 cornall User rank is Second Lieutenant (5000 - 10000 Reputation Level)cornall User rank is Second Lieutenant (5000 - 10000 Reputation Level)cornall User rank is Second Lieutenant (5000 - 10000 Reputation Level)cornall User rank is Second Lieutenant (5000 - 10000 Reputation Level)cornall User rank is Second Lieutenant (5000 - 10000 Reputation Level)cornall User rank is Second Lieutenant (5000 - 10000 Reputation Level)cornall User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 3 Days 8 h 54 m 56 sec
Reputation Power: 84
CSS - Make an area a hyperlink

Is it possible to make an area of a website a hyperlink using css?

e.g. give the position and the size of the area then when somone clciks this area it acts as a hyperlink?

Reply With Quote
  #2  
Old July 4th, 2008, 06:45 PM
markoc's Avatar
markoc markoc is offline
Contributing User
ASP Free Regular (2000 - 2499 posts)
 
Join Date: Nov 2003
Location: UK
Posts: 2,151 markoc User rank is First Lieutenant (10000 - 20000 Reputation Level)markoc User rank is First Lieutenant (10000 - 20000 Reputation Level)markoc User rank is First Lieutenant (10000 - 20000 Reputation Level)markoc User rank is First Lieutenant (10000 - 20000 Reputation Level)markoc User rank is First Lieutenant (10000 - 20000 Reputation Level)markoc User rank is First Lieutenant (10000 - 20000 Reputation Level)markoc User rank is First Lieutenant (10000 - 20000 Reputation Level)markoc User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 18 h 10 m 15 sec
Reputation Power: 201
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;">&nbsp;</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).

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingHTML, JavaScript And CSS Help > CSS - Make an area a hyperlink


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT