locked
Show popup and close it after 5 seg RRS feed

  • Question

  • User-909867351 posted

    Hi

    I'm new at Jquery and I found the following  post

    http://stackoverflow.com/questions/10179040/jquery-dialog-open-and-automatically-close-after-3-seconds

    with the code:

    http://jsfiddle.net/WrdM9/2/

    Here is my asp.net webpage

    <%@ Page Language="VB" AutoEventWireup="false" CodeFile="mensagem.aspx.vb" Inherits="mensagem" %>
    <!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
       
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
        <div id="dialog" style="display:none;">
            <p >ola mru</p>
        </div>
        </div>        
        </form>  
        <script>
        $('#dialog').html('some message');
    
    $('#dialog').dialog({
        autoOpen: true,
        show: "blind",
        hide: "explode",
        modal: true,
        open: function(event, ui) {
            setTimeout(function(){
                $('#dialog').dialog('close');                
            }, 3000);
        }
    });  
    </script>
       <script src="Scripts/jquery-3.1.1.min.js"></script>
    </body>
    </html>

    But it doesn't work

    Any help, please?

    Tuesday, December 6, 2016 5:19 PM

Answers

  • User-691209617 posted

    add one more line for jQuery ui after this line 

      <script src="Scripts/jquery-3.1.1.min.js"></script>

    like this 

    <script src="http://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>

    and add this in head tag

    <link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/ui-lightness/jquery-ui.css">

    and complete code for page will become

    <%@ Page Language="VB" AutoEventWireup="false" CodeFile="mensagem.aspx.vb" Inherits="mensagem" %>
    <!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
       <link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/ui-lightness/jquery-ui.css">
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
        <div id="dialog" style="display:none;">
            <p >ola mru</p>
        </div>
        </div>        
        </form>  
        <script>
        $('#dialog').html('some message');
    
    $('#dialog').dialog({
        autoOpen: true,
        show: "blind",
        hide: "explode",
        modal: true,
        open: function(event, ui) {
            setTimeout(function(){
                $('#dialog').dialog('close');                
            }, 3000);
        }
    });  
    </script>
       <script src="Scripts/jquery-3.1.1.min.js"></script>
       <script src="http://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>
    </body>
    </html>

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, December 6, 2016 6:01 PM