views:

330

answers:

2

Hey everybody,

I'm not a javascript professional so I can't solve the following code alone.

I have a delegate function which works fine in IE7. The Problem in IE8 I figuered out is the last jquery-function click(). Does anybody know how I can solve this for IE 8

thank you in advance.

<script type="text/javascript">
function LightboxDelegate(url,caption)
{
$('#impressionen').attr({
href: url,
title: caption,
alt: caption
});
$('#impressionen').lightBox();
$('#impressionen').click();

};
+1  A: 

I am not sure whether this helps or not. But try replacing

$('#impressionen').click();

with

$('#impressionen').trigger('click');

See

trigger

Trigger an event on every matched element.

rahul
Thanks a lot - with trigger it works fine, but now there is a new Problem in ie8. It seams the the attr()-function also not works. The lightbox apears, but it displays loading all the time.Anybody got a new idea?And thank you all for the rapid help
einflo
Are you sure that lightbox doesn't override some behaviors like clicking?
stoimen
A: 

What is subscribed to that click event?

I would expect the following to work:

//set up event
$('#impressionen').click(function() { 
    alert('it works!');
});

//alert should show in all browsers
$('#impressionen').click();

However this is a simple example - there are other things that can break this. How are you setting up the click event?

Keith