我希望iframe只显示

时间:2016-08-08 10:19:54

标签: php html iframe web-technologies

我有一个iframe,我已将其嵌入到生产网站上。我还在努力here is the iframe the table with results

问题在于我不想让任何人看到它,所以我想知道是否有任何方法可以在链接上添加一些东西。

http://www.chessbook.net/ZULUTESTINGSITE/index.php?option=com_chess&id=350**&result** 

只有在我添加&结果时才会显示iframe 以下是页面上的iframe代码

<div>
   <iframe src="http://users.hellzoneinc.com/eric258/preview.php" width="50%" 
           height="300" scrolling="auto" frameborder="0" name="results"> 
   </iframe>
</div>

2 个答案:

答案 0 :(得分:1)

你应该做以下的事情:

 <?php if(isset($_GET['result']) OR $_GET['result'])=='Your_SOME_VALUE'){?>
<div>
<iframe src="http://users.hellzoneinc.com/eric258/preview.php" width="50%" height="300" scrolling="auto" frameborder="0" name="results"> </iframe>
</iframe>
        </div>
 <?php }?>

您的网址应为

http://www.chessbook.net/ZULUTESTINGSITE/index.php?option=com_chess&id=350&result=Your_SOME_VALUE

答案 1 :(得分:1)

您建议的方法应该非常好用假设包含此HTML的脚本是.php脚本,并将传递给PHP解释器。如果此文件的扩展名不是.php,那么PHP脚本部分当然不会传递给解释器。

        

您需要做的就是这个

<?php
if ( isset($_GET['result']) ) :
?>
    <div>
       <iframe src="http://users.hellzoneinc.com/eric258/preview.php" width="50%" 
               height="300" scrolling="auto" frameborder="0" name="results"> 
       </iframe>
    </div>
<?php
endif;
?>

由于普通访问不会在&result数组中设置此新$_GET参数,因此当您将额外参数添加到网址时,此iframe应仅放置在页面中

注意:您需要测试的是您要添加到原始网址的&result参数的存在,因为您没有向其添加任何值,即您没有$result="something" < / p>

如果您的HTML位于名为something.html的文件中,那么您当然可以复制它并将其命名为something_test.html,然后您就不必费心去参数或添加PHP脚本