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

109,315

Solution 1

You can just use the normal setTimeout method in JavaScript.

ie...

setTimeout( function(){ 
    // Do something after 1 second 
  }  , 1000 );

In your example, you might want to use showStickySuccessToast directly.

Solution 2

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>
Share:
109,315
coder
Author by

coder

I'm a digital marketer as well as passionate about web designing.

Updated on August 01, 2020

Comments

  • coder
    coder almost 4 years

    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