[jquery] How to make a jquery function call after "X" seconds

I have a jquery function and I need to call it after opening the website in an Iframe.

I am trying to open a weblink in an Iframe and after opening it I need to call the below function. So how do I do that?

Here is my function:

<script type="text/javascript">
       $(document).ready(function(){
           $("#<%=Button1.ClientID%>").click(function (event) {

            $('#<%=TextBox1.ClientID%>').change(function () {
                $('#various3').attr('href', $(this).val());
            });
            $("#<%=Button2.ClientID%>").click();
        });
      })
    function showStickySuccessToast() {
        $().toastmessage('showToast', {
            text: 'Finished Processing!',
            sticky: false,
            position: 'middle-center',
            type: 'success',
            closeText: '',
            close: function () {

            }
        });
    }

    </script>

This is my button to open the link in an IFrame:

<a id="various3" href="#"><asp:Button ID="Button1" 
runat="server" Text="Button" OnClientClick="Button2_Click"/></a>

Actually this is the simple Page I'm having:

enter image description here

And this is the message enter image description here

This question is related to jquery function call settimeout

The answer is


If you could show the actual page, we, possibly, could help you better.

If you want to trigger the button only after the iframe is loaded, you might want to check if it has been loaded or use the iframe.onload:

<iframe .... onload='buttonWhatever(); '></iframe>


<script type="text/javascript">

    function buttonWhatever() {
        $("#<%=Button1.ClientID%>").click(function (event) {
            $('#<%=TextBox1.ClientID%>').change(function () {
                $('#various3').attr('href', $(this).val());
            });
            $("#<%=Button2.ClientID%>").click();
        });

        function showStickySuccessToast() {
            $().toastmessage('showToast', {
                text: 'Finished Processing!',
                sticky: false,
                position: 'middle-center',
                type: 'success',
                closeText: '',
                close: function () { }
            });
        }
    }

</script>

try This

setTimeout( function(){ 
    // call after 5 second 
  }  , 5000 );

Examples related to jquery

How to make a variable accessible outside a function? Jquery assiging class to th in a table Please help me convert this script to a simple image slider Highlight Anchor Links when user manually scrolls? Getting all files in directory with ajax Bootstrap 4 multiselect dropdown Cross-Origin Read Blocking (CORB) bootstrap 4 file input doesn't show the file name Jquery AJAX: No 'Access-Control-Allow-Origin' header is present on the requested resource how to remove json object key and value.?

Examples related to function

$http.get(...).success is not a function Function to calculate R2 (R-squared) in R How to Call a Function inside a Render in React/Jsx How does Python return multiple values from a function? Default optional parameter in Swift function How to have multiple conditions for one if statement in python Uncaught TypeError: .indexOf is not a function Proper use of const for defining functions in JavaScript Run php function on button click includes() not working in all browsers

Examples related to call

ReactJS - Call One Component Method From Another Component Call a Class From another class What does it mean to "call" a function in Python? How to make method call another one in classes? How to call a mysql stored procedure, with arguments, from command line? Submit form on pressing Enter with AngularJS Running bash script from within python javascript: get a function's variable's value within another function Passing variables, creating instances, self, The mechanics and usage of classes: need explanation Android Call an method from another class

Examples related to settimeout

setInterval in a React app setTimeout in React Native Combination of async function + await + setTimeout How to make a promise from setTimeout How to make `setInterval` behave more in sync, or how to use `setTimeout` instead? Express.js Response Timeout Difference between setTimeout with and without quotes and parentheses How to stop a setTimeout loop? How to make a jquery function call after "X" seconds What is the equivalent to a JavaScript setInterval/setTimeout in Android/Java?