Open in new window
Here’s how to make a div into a clickable link that will open the target URL into a new window.
1 2 3 4
<div onclick="window.open('http://www.brightcherry.co.uk/');"> </div>
Open in same window
Here’s how to make a div into a clickable link that will open the target URL into the same window.
1 2 3 4
<div onclick="window.location = 'http://www.brightcherry.co.uk/';"> </div>
The links CAN be relative to the domain, they don’t just work with full URLs. You can use URLs like “/dir/index.html”
This blog post was written on 30 Mar 2011 by Maruf, and has 2 Comments so far
Learning & sharing
This is where we store some of our Web Development thoughts, tips and tricks for both our own uses and for others to learn from. Sharing is caring.
Please feel free to contrinute to our blog posts; perhaps even teach us a few tricks of your own. We'd love to hear your thoughts.