我有一个iframe,我将它嵌入到一个生产站点中。我仍然在工作,这里是iframe表与结果
问题是我不想让任何人看到它,所以我想知道有没有办法添加一些东西到链接看起来像。
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>
你应该这样做:
<?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 }?>
URL应该是
http://www.chessbook.net/ZULUTESTINGSITE/index.php?option=com_chess&id=350&result=Your_SOME_VALUE
假设包含此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;
?>
由于正常访问将不会在$_GET
数组中设置这个新的&result
参数,因此只有当您向url添加额外参数时,才应该将该iframe放置在页面中
注意:所有你需要测试的是你添加到原始URL的&result
参数的存在,因为你没有添加任何值给它,即你没有做$result="something"
如果你的HTML在一个名为something.html
的文件中,那么你当然可以复制它并将其命名为something_test.html
,然后你就不必为参数或PHP脚本添加而烦恼了