can someone help me in generating auto click html code RRS feed

  • Question

  • User2001694453 posted
    can someone help me in generating a html code which automatically clicks anywhere on current webpage after the webpage has been opened for 5-6 seconds
    Thursday, August 2, 2018 2:36 AM

All replies

  • User-369506445 posted


    setTimeout() && jQuerys .trigger()should do it:

    setTimeout(function() {
    }, 4e3);

    Demo: http://jsfiddle.net/WTJgt/9/

    In reference to your comment, just change the selector. Query by classname:

    Thursday, August 2, 2018 4:37 AM
  • User2001694453 posted
    thanks for replying i don't want a code to click a specific button i want it to be clicked any where on current tab after someone has been 5-6 seconds
    Thursday, August 2, 2018 11:38 AM
  • User-369506445 posted

    This was a sample, you can define a html tag such as <span> or< p> or ... and you can set dispaly as none and in the code , put this tag id instead of the buton

    Thursday, August 2, 2018 12:13 PM
  • User2001694453 posted
    I'm not so much into html can you please edit it and send it to me
    Friday, August 3, 2018 12:23 AM
  • User-893317190 posted

    Hi yoyoaman,
    I am not clear about what you mean  by the expression  “auto click html code”?
    Where do you register the click event ? Or You haven’t register any click event  and just want to register a click event  that could be triggered  anywhere in the web page after 5-6 second?
    If you have written any code ,which even hasn’t been finished , could you please post it so that we could learn more about what you want to do ?
    If you want  to   register a click event  anywhere in the webpage, you could refer to the code below. I  register  an event  on the whole document and in its click event I unbind the event  so that the click event will only be fired for one time.
    SetTimeout method sets a timer , which will run the function you specify as the first argument of the method. The second argument specifies  the time after which to run the function. The unit is millisecond. 

    setTimeout(function () {
            $(document).click(function () {
                alert("you couldn click me anywhere after three seconds");
        }, 3000)

    Best regards,

    Ackerly Xu

    Friday, August 3, 2018 9:52 AM
  • User-2054057000 posted

    You can use a bit of jQuery to execute a click to an element automatically after a specified seconds. I think you are a beginner so I explain you from the beginning. First go to the page head section and add the jQuery from ASPNET CDN:

    <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.2.1.min.js"></script>

    Then add the document ready which tells to execute the code when the html document is loaded:

    $(document).ready(function() {

    Finally you write your jQuery code inside it.

    To execute the click code after 5 seconds you use the setTimeout function. It will execute a specified function after the desired time (in millseconds).

    setTimeout(clickFunction, 2000);
    function clickFunction() { alert('Function executes'); }

    To click an element in jQuery you simply use the .click() method. Now suppose that element id (which has to be clicked) has id as - 'myElementId'. So in jQuery you do - 


    So The full code which you need is

    <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.2.1.min.js"></script>
    $(document).ready(function() {
    setTimeout(clickFunction, 5000); 
    function clickFunction() { $("myElementId").click(); } }); </head>

    5000 is the milliseconds which evaluates to 5 seconds.

    Reference Tutorial

    Friday, August 3, 2018 7:52 PM