Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: IE7 ASP.NET Javascript
I have written code like,

document.getElementById("<%= btnVillageSearch.ClientID %>").click();

To Perform Click Operation which working in Mozilla Firefox, But while coming to IE,

It is not supporting. Please tell me how to perform button click from Java Script for

IE.
Posted 11-Oct-12 21:28pm
Edited 12-Oct-12 0:02am
DaveAuld181.5K
v2
Comments
Aman.A at 12-Oct-12 2:56am
   
Are u missing a "#" after "<%"? The other thing u could try is set the clientidmode property to static of the button and then access the id directly in your JavaScript as a literal string. See if that works.

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

var btn = document.getElementById('<%=btnDummy.ClientID%>');
btn.click();
This is something i have used previously and can confirm it works in IE. , also try moving the the script block to the end of the page, it might also have something to the version of IE you are using.

Or you can try this, this is something i used in Safari which wouldnt otherwise fire the click() event properly
var dispatch = document.createEvent("HTMLEvents")
dispatch.initEvent("click", true, true);
document.getElementById('<%=btnDummy.ClientID%>').dispatchEvent(dispatch);

Hope it helps.
  Permalink  
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 6,425
1 OriginalGriff 5,918
2 Peter Leow 2,514
3 Maciej Los 2,263
4 Abhinav S 2,249


Advertise | Privacy | Mobile
Web01 | 2.8.150414.1 | Last Updated 12 Oct 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100