drkj41932
2013-11-29 00:24
浏览 264
已采纳

在iframe html标签中使用php

I am trying to create a website that displays another website in an iframe.

This is my code:

<html> 
<title>HTML with PHP</title>
<style>
body {
margin: 0px;
}
</style>
<body>
<?php
$page = $_GET['query'];
echo $page;
?>
<iframe align="center" width="100%" height="100%" src="<?=$page;?>" frameborder="yes" scrolling="yes" name="myIframe" id="myIframe"> </iframe>
</body>
</html>

When I open the php file off of my website (using a url website.com/file.php?query=https://www.google.com, and look in the inspector, I can see the page that the iframe loaded, but it just shows up as a blank page, not the . I have it up at http://www.test.fire-light.tk/web.php?query=url (replace url with any valid url). I am not sure why it shows the blank page.

图片转代码服务由CSDN问答提供 功能建议

我正在尝试创建一个在iframe中显示另一个网站的网站。 < p>这是我的代码:

 &lt; html&gt;  
&lt; title&gt; HTML with PHP&lt; / title&gt; 
&lt; style&gt; 
body {
margin:0px; 
} 
&lt; / style&gt; 
&lt; body&gt; 
&lt;?php 
 $ page = $  _GET ['query']; 
echo $ page; 
?&gt; 
&lt; iframe align =“center”width =“100%”height =“100%”src =“&lt;?= $ page;?&gt;  ;”  frameborder =“yes”scrolling =“yes”name =“myIframe”id =“myIframe”&gt;  &lt; / iframe&gt; 
&lt; / body&gt; 
&lt; / html&gt; 
   
 
 

当我从我的网站打开php文件时(使用网址。 com / file.php?query = https://www.google.com ,并查看检查员,我 可以看到iframe加载的页面,但它只是显示为空白页面,而不是。我把它放在 http://www.test.fire-light.tk/web.php?query=url (用任何有效的网址替换网址)。我不确定 为什么它显示空白页。

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • dongying7847 2014-04-03 18:21
    已采纳

    I think this:

    <iframe align="center" width="100%" height="100%" src="<?=$page;?>" 
      frameborder="yes" scrolling="yes" name="myIframe" id="myIframe"> </iframe>
    

    should be changed into:

    <iframe align="center" width="100%" height="100%" src="<? echo $page; ?>"  
      frameborder="yes" scrolling="yes" name="myIframe" id="myIframe"> </iframe>
    
    已采纳该答案
    打赏 评论
  • douhuangzhi0707 2013-11-29 00:46

    Try this instead:

    <html> 
    <title>HTML with PHP</title>
    <style>
    body {
    margin: 0px;
    }
    </style>
    <body>
    <?php
    $url = $_SERVER['REQUEST_URI'];
    $parts = explode('?=', $url);
    $page = $parts[1];
    echo '<iframe align="center" width="100%" height="100%" src="$page" frameborder="yes" scrolling="yes" name="myIframe" id="myIframe"> </iframe>';
    ?>
    </body>
    </html>
    
    打赏 评论
  • donglu5041 2016-08-12 02:50

    Using Iframe you can call PHP file in HTML file . And write your PHP code in test.php Iframe code <iframe src="test.php"></iframe>

    打赏 评论

相关推荐 更多相似问题