简体   繁体   中英

Internet Explorer 8 JQuery Click() function not working

I am really struggling with IE8 not recognizing my JQuery Click() function. Chrome and FF works fine. I have searched through several pages of google search for the right answer but have yet to identify a solution. I came across several stackoverflow posts, but no result. Usually the situations are way more complicated than what I am doing.

<a id="modalwindow" class="thickbox" href="iframemodal.html?placeValuesBeforeTB_=savedValues&TB_iframe=true&height=300&width=425&modal=true"></a>

<script language="javascript">
//<!--
$(document).ready(function(){
        $('#modalwindow').click();
});
//-->
</script>

Pretty simple yes? I am trying to force a "click" on the link that is using a thickbox plugin to pop up a modal-style window. I also tried using

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

But that will not work either. I am getting no javascript errors, and I can do alerts before and after the click() and they function fine. I hope someone can help.

Hi I'm also have this problem . This cause my button interaction are delayed with the real result we want .

My situation is that I have two button A and B

If I click A than B should be click ( or show it is click by some mean to represent it )

$("A").click(function(){
   $("B").trigger("click");
})

but when I testing it on firefox and chrome are not delayed .

and when I testing it on ie8 ( embeded in ietester ) I should click A button two times and the B button would show click status .

my first way to resolve this problem is that change the trigger to click

$("A").click(function(){
   $("B").click();
})

but still delayed on ie 8

and I do this twise

$("A").click(function(){
  $("B").click();
  $("B").click();
 })

then it works fine .

I don't know wether you could solve by the final method I did .

When I test it , it works fine ~

The click event call will not enforce an actual click, but it will call any click handler code that you may have. If you want to have the link "clicked", then do this:

location.href = $('#modelwindow').attr('href');

See this: jquery click doesn't work on hyperlink

JQuery's click() doesn't actually click on the link, it just executes all attached event handlers.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM