如何在“X”之后调用jquery函数秒 [英] How to make a jquery function call after "X" seconds

查看:91
本文介绍了如何在“X”之后调用jquery函数秒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我试图在iframe中打开一个web链接,并在打开网页之后打开它。

我有一个jquery函数,我需要在打开iframe中的网站后调用它。我需要调用下面的函数。
所以我该怎么做?



以下是我的函数:

 < script type =text / javascript> 
$(document).ready(function(){
$(#<%= Button1.ClientID%>)。click(function(event){
$ b $ $('#<%= TextBox1.ClientID%>')。change(function(){
$('#various3')。attr('href',$(this).val() );
});
$(#<%= Button2.ClientID%>)。click();
});
})
函数showStickySuccessToast(){
$()。toastmessage('showToast',{
text:'Finished Processing!',
sticky:false,
position:'middle-中心',
类型:'成功',
closeText:'',
close:function(){


});
}

< / script>

这是我在IFrame中打开链接的按钮:

 < a id =various3href =#>< asp:Button ID =Button1
runat =serverText =按钮OnClientClick =Button2_Click/>< / a>

实际上,这是我正在使用的简单网页:


这是消息

解决方案

您可以在JavaScript中使用正常的setTimeout方法。



ie ...

  setTimeout(function(){
//在1秒后做某事
},1000);

在您的示例中,您可能需要使用 showStickySuccessToast

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:

And this is the message

解决方案

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.

这篇关于如何在“X”之后调用jquery函数秒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆