![]() |
| ||
| Using <div onclick="""> to call an <a></a> link Is it possible to do something like this? <div id="btn1" onclick="//somehow call page2Link here"><a href="page2.html" id="page2Link">Page 2</a></div> Basically it's to try and make the text work with the a:hover text effect I have whilst making the whole layer sensitive to clicks. i tried this already: <a href="page2.html" id="page2Link"><div id="btn1" ><a href="page2.html" id="page2Link">Page 2</a></div></a> but it's untidy and a bit rubbish is there a better way to do it neatly? I know i could always call a JS function to do a parent.location thing but i would rather not if possible. |
| ||
| Re: Using <div onclick="""> to call an <a></a> link Hi there, have you tried: <div id="blah" onclick="window.location = 'Your reference here'> |
| ||
| Re: Using <div onclick="""> to call an <a></a> link cheers i'll give that a go |
| ||
| Re: Using <div onclick="""> to call an <a></a> link You can leave out the <a> tag then because you can just use the div:hover. <div id="myButton" onclick="window.location = 'http://google.com';">Page 2</div> |
| ||
| Re: Using <div onclick="""> to call an <a></a> link But, if you leave out the anchor tag the styles you've applied won't work... but i suppose you could just change them from a:hover etc. to div:hover. |
| ||
| Re: Using <div onclick="""> to call an <a></a> link What I end up doing quite a bit, is making the div clickable, but allowing for people without javascript to access the link (such as search spiders). One way to do this is using jquery -- $(function(){Which allows for the div to be clickable. |
| ||
| Re: Using <div onclick="""> to call an <a></a> link Quote:
|
| ||
| Re: Using <div onclick="""> to call an <a></a> link Thanks to all. Problem now solved. ps. Give JQuery a rest some of us like to code in an old school manner where all the code is ours rather than being cut & paste monkeys. |
| ||
| Re: Using <div onclick="""> to call an <a></a> link Quote:
Its also sometimes hard to relearn something too... |
| All times are GMT -4. The time now is 2:33 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC