0

我在我的母版页上创建了一个 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> 
4

1 回答 1

0

我们可以使用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);
}
}
}
于 2012-08-22T09:42:57.797 回答