2017-01-17 48 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