You must Sign In to post a response.
  • Category: ASP.NET

    How to invoke Anchor tag click event without clicking in


    I am working on a application. In this I want a javascript function which have to invoke Anchor tag click event without clicking in

    If anyone have any idea to do this please reply me.

    Thanks in advance.
  • #450265
    What the action you want to do. and in which scnario you want to raise the anchor click event. Without clicking to raise the click event is not the right way.
    You tell clearly the requirement then can get the way.

  • #450268

    Try below code:



  • #450272
    Hi Rajapandian,

    Thank you for your quick reply.
    I tried you code but I am not getting click() function in aspx page Javascript.

    If you have any other solution please reply me.

    Thanks in advance

  • #450274
    Hi Madhu,

    Actually I have to call javascript function in aspx page from a silverlight page. In this Javasript function I need to navigate to a page in lightbox style. I have code for displaying a page in light box style only on clicking a anchor tag. So for navigating to a page and displaying it in a light box style I want a Javascript function which will invoke anchor tag click event without clicking

    If you have any solution to solve this please reply me.

    Thanks in advance

  • #450275

    click will not be displayed in Intellisense. But if you write the code, it will work.

    I tested this code from my end.


  • #450277

    You are showing the Lightbox for what. In all the cases you are showing the popup or only in a particualr case.
    Confirm the occassion you need to show the page in light box.

    I think if a user is trying for some action , if does not allow for that then need to show another page. When ever that action fails call thos JS method.

  • #450293
    Hi Rajapandian,

    Thank you for your reply.
    I tried it but it is giving error. Below is the error.


    Can you please share your code with me so that I will check it.
    Please reply me how to solve this.

    Thanks in advance

  • #450296
    function ClickAnc()

    <a onclick="alert('anchor clicked');" id="anchor">Anchor</a>
    <asp:Button ID="btn1" runat="server" Text="Click Anchor" OnClientClick="ClickAnc(); return false;" />


  • #450365
    Thank you Rajapandian

    Now it is working. Here problem is with the Quotation marks.

    document.getElementById('anchor').click(); is working but I tried with
    document.getElementById("anchor").click(); so it didn't worked.

    Now it is fne

  • #450383
    Hi Rajapandian,

    Again I have a problem with this. That is it(Javascript) is working in IE but it is not working in Mozilla Firefox.
    Please reply me how to solve this.

    Thanks in advance.

  • #450890

    Try below code



  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.