I have a div which has an a inside it. I want to click on the div and follow the same url as the a. This is the HTML:
<div class=overview white getchildurl>
<p class=w70>
05-02-2011
</p>
<a class=button href=details/>Details</a>
<span class=clear></span>
</div>
and I have this script:
$('.getchildurl').each(function() {
$(this).click(function() {
var href = $(this).children('a').first().attr('href');
window.location = href;
});
});
This works in Firefox 3.6, Chrome, Safari, but not in IE7 and IE8. It reloads the page, but stays on the same page. I checked the var href, it has the right url, but doesn't go there. What am I doing wrong?
Thanks.
EDIT: Making it an absolute URL made it work. This is the new script:
$('.getchildurl').each(function() {
$(this).click(function() {
var href = $(this).children('a').first().attr('href');
var host = window.location.hostname;
window.location = 'http://' + host + '/' + href;
});
});