2014-02-27 38 views
0

我有3个asp.net页面。 点击PAGE 1链接导航到Modal Popup的第2页。 点击PAGE 2链接关闭模式弹出并导航到主窗口上的页面3。 当浏览器返回按钮被点击,而我在页面3上时,我想回到模式弹出(第2页)。当浏览器返回按钮被点击时,它现在导航到页面1。 如果有任何建议,请让我知道吗?谢谢。浏览器后退按钮显示模式窗口

回答

0

您可以使用javascript cookie来检查模式是否已经打开过。

注意:我已经在我的机器上本地测试了这些代码,并且出现了很多脚本限制。你可以阅读有关JS cookie,并在W3Schools

<body onload="checkModal()"> 
    <script type="text/javascript"> 
     function openModal(){ 
      document.cookie = 'modalopened=true'; 
      alert('Modal page'); // Open your modal here 
     } 

     function checkModal() 
     { 
      if (document.cookie == 'modalopened=true') 
      {  
       openModal(); 
       document.cookie = ''; 
      } 
     } 
    </script> 

    <input type="button" onclick="openModal()" value="Open"> 
    <a href="http://stackoverflow.com">Go to another page and come back here.</a> 
</body> 
-1

在线测试呈三角例子试试这个

<script type="text/javascript"> 
function goBack() 
{ 
window.history.go(-1) 
} 
</script> 
<a href="#" id="btnreturnback" runat="server" onclick="javascript:goBack();return false;"></a>