2

我有一个 iframe,我已将其嵌入到生产站点中。我仍在处理这里是带有结果的表的 iframe

问题是我不想让任何人看到它,所以我想知道有没有办法在链接外观中添加一些东西。

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

这样,只有当我添加 &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>
4

2 回答 2

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
于 2016-08-08T10:27:14.453 回答
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,因此只有在将额外参数添加到 url 时,才应将这个 iframe 放置在页面中

注意:您需要测试的只是&result您添加到原始 URL 的参数是否存在,因为您没有向它添加任何值,即您没有做$result="something"

如果您的 HTML 在一个名为的文件中,something.html那么您当然可以复制它并调用它something_test.html,然后您不必为参数或 PHP 脚本添加而烦恼。

于 2016-08-08T12:13:37.360 回答