views:

123

answers:

1

I have a image map set up and each area in the image map has a href defined. the href on area contains urls to other pages in my application. i generate a small list (ul, li) which lists down the name attribute of the area tag. i want the dynamically generated ul/lis to imitate click behaviour of area tag. for this, i have the following jquery set up -

 $('li').click(function(e){
       $('area[name='+$(this).html()+']').trigger('click');
 });

but the above works well only in ie6+. ff does not fire the click event. i also tried the click() variant but to no avail.

looking forward for some help.

Thanks :)

+1  A: 

In FireFox' case, triggering the click event fires the onClick handlers bound to the element (in this case your li elements), but does not actually follow the link. As I understand it, you want the clicks to follow the link of the area associated with the li element

Try this, this fetches the href attribute of the associated area and redirects using javascript

$('li').click(function(e){
    var $area = $('area[name='+$(this).html()+']');
    var url = $area.attr("href");
    document.location.href = url;
});
Simen Echholt
thanks a lot :) it worked!
Amit