2017-01-17 131 views
0

我有一個具有以下結構的頁面主頁。在投資組合部分,我嵌入了一個貝寶按鈕。我打算使用paypal的自動返回功能,買家在付款完成後返回到我的頁面。而在聯繫方式部分,我嵌入了一個iframe,這是一個使用谷歌文檔進行的調查。我想只顯示購買者完成購買。我怎樣才能做到這一點?以條件顯示和隱藏iframe

<!DOCTYPE HTML> 
<html> 
<head> 
    <title>Mini</title>  
</head> 
<body> 

    <!-- Nav --> 
     <nav id="nav"> 
      <ul class="container"> 
       <li><a href="#top"></a></li> 
       <li><a href="#work"></a></li> 
       <li><a href="#portfolio"></a></li> 
       <li><a href="#contact"></a></li> 
      </ul> 
     </nav> 

    <!-- Home --> 
     <div class="wrapper style1 first"> 
      <article class="container" id="top"> 
        <div> 
        </div>     
      </article> 
     </div> 

    <!-- Work --> 
     <div class="wrapper style2"> 
      <article id="work">     
       <div class="container"> 
        <div class="row"> 
        </div> 
       </div> 
      </article> 
     </div> 

    <!-- Portfolio --> 
     <div class="wrapper style3"> 
      <article id="portfolio">      
       <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top"> 
       //Here is the paypal button 
       </form> 
      </article> 
     </div> 

    <!-- Contact --> 
     <div class="wrapper style4"> 
      <article id="contact" class="container 75%">      
        <div class="row"> 
         //below the survey made with google docs 
         <iframe src="https://docs.google.com/forms/...</iframe> 
        </div> 

      </article> 
     </div> 

    <!-- Scripts --> 
</body> 

+0

喜檢查和驗證返回URL,也許你可以使用[HTML5本地存儲(http://www.w3schools.com/html/html5_webstorage.asp)試試。 – Goku

回答

0

您可以檢查引薦

JavaScript解決方案

<script> 
    var referrer = document.referrer; 
    if (referrer == 'paypal domain here') { 
     document.getElementById("iframeidhere").style.display = "block"; 
    } 
</script> 

而且同一ID添加到該iframe,並添加style="display:none";

PHP解決方案

<?php if ($_SERVER['HTTP_REFERER'] == 'here you put PayPal domain') { ?> 
    // Your iframe here 
<?php } ?> 

你不能依賴它100%,有人可以欺騙這個變量,但如果它是不是安全問題,爲您的谷歌的形式,它是方便,快捷的解決方案。

其他的解決辦法是來自PayPal

+0

感謝您的輸入。我會盡快嘗試。 – RedSea