【问题标题】:displaying a php file in an iframe using codeigniter使用 codeigniter 在 iframe 中显示 php 文件
【发布时间】:2013-04-29 20:18:24
【问题描述】:

大家好,我正在尝试学习 codeigniter,但在 iframe 中显示 php 文件时遇到了问题。这是我的代码。它返回“404 页面未找到”

这是我的看法:

<iframe class="tabContent" name="myIframe" src="<?php echo site_url('pages/view_about');?     >" marginheight="8" marginwidth="8"></iframe>

然后这是我的控制器:

  function view_about(){

    $this->load->view('pages/about');
}

这是我的文件夹的排列方式

application->views->pages->about.php

应用程序->控制器->pages.php

我想补充一下,我上面粘贴的用于我的视图的代码位于

应用程序->视图->模板->footer.php

iframe 实际上是我页脚的一部分,谢谢

【问题讨论】:

  • 尝试将 URL 插入到 broser 中,它可能无法正常工作。检查输出到 iframe 的 URL 是什么
  • 在控制器中发布 pages.php 的内容..
  • 我尝试在浏览器localhost/projectname/index.php/about 中插入这个url,它显示了about.php
  • 所以index.php/about 不是index.php/pages/view_about

标签: php codeigniter iframe


【解决方案1】:

php结束标签之间有空格

试试这个..

<iframe class="tabContent" name="myIframe" src="<?php echo site_url('pages/view_about'); ?>" marginheight="8" marginwidth="8"></iframe>

【讨论】:

  • @pic-a 如果此链接http://localhost/projectname/index.php/about 在浏览器中有效,您必须使用&lt;?php echo site_url('about'); ?&gt;
  • 感谢您的回复,我照您说的做了,但是当我输入 echo site_url('about') 时,它会在我的 iframe 中显示整个页面
  • @pic - 在你的控制器中更改为echo $this-&gt;load-&gt;view('pages/about','',true);
  • 我按照你说的做了,但整个页面仍然出现在 iframe 中
【解决方案2】:

您好,请尝试以下代码,希望它对您有用。

<a href="/pages/page" target="targetFrame">Page 1</a>
<iframe id="targetFrame" src="" width="100%" height="100%" scrolling="NO" frameborder="0" ></iframe> 

【讨论】:

  • 我试过了,但没有用,我用文件的位置更改了页面/页面,但仍然没有用
猜你喜欢
  • 1970-01-01
  • 2012-03-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-11-05
  • 1970-01-01
  • 2012-06-24
  • 2013-03-03
相关资源
最近更新 更多