I have a I\'m looking for something l
While I don't recommend doing this under any circumstance, here is some code that makes a DIV into a link (note: this example uses jQuery and certain markup is removed for simplicity):
<script type="text/javascript" src="jquery-1.3.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("div[href]").click(function () {
window.location = $(this).attr("href");
});
});
</script>
<div href="http://www.google.com">
My Div Link
</div>
<a href="…" style="cursor: pointer;"><div> … </div></a>
This work for me:
<div onclick="location.href='page.html';" style="cursor:pointer;">...</div>
I pulled in a variable because some values in my link will change depending on what record the user is coming from. This worked for testing :
<div onclick="location.href='page.html';" style="cursor:pointer;">...</div>
and this works too :
<div onclick="location.href='<%=Webpage%>';" style="cursor:pointer;">...</div>
This is the simplest way.
Say, this is the div
block I want to make clickable:
<div class="inner_headL"></div>
So put a href
as follows:
<a href="#">
<div class="inner_headL"></div>
</a>
Just consider the div
block as a normal html element and enable the usual a href
tag.
It works on FF at least.
This is an ancient question, but I thought I'd answer it since everyone here has some crazy solutions. It's actually very very simple...
An anchor tag works like this -
<a href="whatever you want"> EVERYTHING IN HERE TURNS INTO A LINK </a>
Sooo...
<a href="whatever you want"> <div id="thediv" /> </a>
Although I'm not sure if this is valid. If that's the reasoning behind spoken solutions, then I apologise...