2013-10-23 1 views
0
나는이 작업을 수행 할

:오버레이 window.history.go (-1)에

사용자가 구글 광고-단어를 통해 우리의 페이지에 도착하고 자신의 브라우저에서 뒤로 버튼을 통해 그것을 떠나려고 할 때, 나는 그에게 몇 가지 물건으로 렌더링 된 오버레이를 보여주고 싶다. ("우리에게 전화하면, 우리가 도와 줄거야!"라고 ...). 물론 사용자는이를 닫고 Google로 돌아갈 수 있습니다.

사용자가 브라우저에서 "뒤로"버튼을 누르면 이벤트 핸들러를 가져와 내 팝업을 팝업 할 수 있습니까? :-)

또한 링크를 누르거나 페이지를 다시로드해도 영향을 미치지 않습니다. 독일

+0

방법을 찾으면 알려주세요. ^^하지만 표준 경고창이 없으면 불가능하다고 생각합니다. 경고를 대체 할 수는 있지만 무언가를 추가 할 수는 있습니다 ... – Petra

답변

0

에서

인사 당신은 오버레이하고 사용자에게 표시 할 정보를 포함하는 대화 상자가 될 것 사업부를 작성해야합니다. 이벤트가 트리거되면 jquery.show()를 사용하여 오버레이와 대화 상자를 표시하십시오.

당신은 이런 식으로 뭔가를 시도 할 수 :

<html> 
    <head> 
     <style type="text/css"> 
      #fullscreen { display:none; position: fixed; z-index:500; min-height: 100%; min-width: 1024px; width: 100%; height: auto; background-color: #565656; top:0; left:0px; margin:0; padding:0; opacity: .5;-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(opacity=50)"; filter: alpha(opacity=50);}  
      #myDialog {display:none;} 
     </style> 
    </head> 
    <body> 
     <div id="fullscreen"></div> 
     <div id="myDialog title="My Dialog Title" ></div> 
    </body> 

    <script type="text/javascript> 
$(document).ready(function() { 
    //When the user attempts to navigate away from the current page... 
    $(window).unload(function() { 
     $('fullscreen').show(); 

      $(function() { 
       $("#myDialog ").dialog({ 
        resizable: false, 
        closeOnEscape: false, 
        width: 660, 
        modal: true, 
        open: function (event, ui) { 
         //hide close button. 
         $(this).parent().children().children('.ui-dialog-titlebar-close').hide(); 
        }, 
        buttons: { 
         "OK": function() { 
          $(this).dialog("close"); 
          $("fullscreen").hide(); 
          window.location = "http://mypage.com"; 
         }, 
         "No, thanks": function() { 
          $(this).dialog("close"); 
          $("fullscreen").hide(); 
         } 
        } 
       }); 
      }); 
     }); 
    }); 
}); 
</script> 
</html> 

그런 다음 필요한 모든 행동을한다. jQuery의 이러한 측면에 익숙하지 않은 경우 대화 상자의 설명서를 살펴 보는 것이 좋습니다. http://jqueryui.com/dialog/

+0

빠른 응답을 보내 주셔서 감사합니다. 나는 자신을 분명히하지 않았다고 생각합니다. 사용자가 Google로 '돌아 오는 것을 방지하는 방법'에 대해 오버레이에 대해 자세히 설명합니다. –