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:
I am posting this as a different answer because it is a different answer. How to work through problem with JavaScript instead of work through it with HTML and CSS.
Try changing your JavaScript to display and make sure the values are what you think they are
$(this).click(function() {
var href = $(this).children('a').first().attr('href');
alert(href)
alert(href.length)
window.location = href;
});
That will display the href
and the href
length. Make sure the length matches up. If the length is too big then that means there are hidden characters.
If you determine that the problem is due to syntax, many URL fixes/conversions can be done with JavaScript. For example, removing a trailing slash when there is one can be done with
$(this).click(function() {
var href = $(this).children('a').first().attr('href');
window.location = href.replace(/\/$/, '');
});
Also, the URL could be converted to an absolute URL using JavaScript if that is what will fix the problem. And any other troublesome or even invisible characters can be either removed or replaced.
Can you post a web page on the internet that we can access to see the issue on our own copies of IE? Can you post an HTML file that we can copy to our machine and view in a browser? Your comment on the other question tells me you have some sort of XHTML strict DOCTYPE. If one of us can make the issue happen on our end, it is more likely to be fixed.