【问题标题】:how to disable the Jqueryui dialogbox when the page load at secondtime页面第二次加载时如何禁用Jquery Ui对话框
【发布时间】:2012-04-14 13:54:49
【问题描述】:

我在我的母版页上创建了一个 jquery ui 对话框,所以在我的站点中,对话框出现在所有页面中,之后我使用 clickevent 关闭对话框,当我再次打开下一页对话框时。一旦我关闭对话框,它应该在下一个页面加载时不打开。请给我一些想法。 我该怎么做??

这是我的 jquery 代码:

 <script type="text/javascript">

  $(document).ready(function () {

  $("#dialog").dialog({ modal: false, resizable: false,
 bgiframe: true, draggable: false, position: ['right', 'bottom'], height: 150,     width:     300
 });


 $("#<%=btnCancel.ClientID%>").click(
  function () {
    $("#dialog").dialog('close');
 return false;
  });
   $("#<%=btnyes.ClientID%>").click(
  function () {
 var url = ".....";
  $(location).attr('href', url);
 return false
    });

      });
  </script>

这是我的设计代码:

  <div id="dialog" title="How Are We Doing?" style="width:500px; margin:0 0;"  background-color="white">

    <asp:Label ID="Label1" runat="server" Text="Please take a minute to give us your feedback…MICROMO.com’s User Feedback Program."></asp:Label>
    <asp:Button ID="btnyes" runat="server" Text="YES" BackColor="#0099cc" width="40px" ForeColor="White" Font-Bold="true" />
    <asp:Button ID="btnCancel" runat="server" Text="NO" width="40px" BackColor="#0099cc" ForeColor="White" Font-Bold="true"/>

     </div> 

【问题讨论】:

    标签: jquery-ui dialog


    【解决方案1】:

    我们可以使用JS Cookie函数在Document.ready函数之前设置显示对话框的条件.. 下面我给出了功能代码:

    <script type="text/javascript">          
    $(document).ready(function ()  
    {
    var check=getCookie("clicked");alert(check);
    if (check!='true' && check!="")
    {    
    
    $("#dialog").dialog({ modal: false, resizable: false,
    bgiframe: true, draggable: true, position: ['right', 'bottom'], height: 150,     
    width:     300
    
    });
    
    }
    
    $("#<%=btnCancel.ClientID%>").click(
    
    function () {
    $("#dialog").dialog('close');
    $("#dialog").dialog('disable');
    return false;
    });
    $("#<%=btnyes.ClientID%>").click(
    function () {
    var url = "http://www.w3schools.com/jquery/jquery_intro.asp";
    $(location).attr('href', url);  
    setCookie("clicked",true,2);    
    return false
    });
    });
    </script>
    

    Cookie Js 文件

    function setCookie(c_name,value,exdays)
    {
    var exdate=new Date();
    exdate.setDate(exdate.getDate() + exdays);
    var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
    document.cookie=c_name + "=" + c_value;
    }
    function getCookie(c_name)
    {
    var i,x,y,ARRcookies=document.cookie.split(";");
    for (i=0;i<ARRcookies.length;i++)
    {
    x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
    y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
    x=x.replace(/^\s+|\s+$/g,"");
    if (x==c_name)
    {
    return unescape(y);
    }
    }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-12-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多