ci怎么载入含有frameset框架的视图?
RT终于搞完了登入登出部分,现在开始做界面了,第一个问题都难倒我了,我写的html模版,单独显示完全正常,一旦用控制器载入,就完蛋了,什么都显示,贴出代码如下,
这是控制器部分的代码:
function index()
{
//redirect('http://192.168.1.8/application/views/sys/index.htm');
$this->load->view('sys/index.htm');
}
这是视图部分代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>OA/CRM集成办公系统 V1.0</title>
</head>
<frameset rows="76,*,20" frameborder="1" framespacing="0" border="1">
<frame name="banner" id="banner" frameborder="1" scrolling="no" noresize="noresize" src="http://192.168.1.8/index.php/index/echobanner">
<frameset cols="176,*" border="1" frameborder="1" framespacing="0">
<frame name="menu" id="menu" frameborder="1" scrolling="no" noresize="noresize" src="http://192.168.1.8/index.php/index/echomenu">
<frame name="body" id="body" frameborder="1" scrolling="no" noresize="noresize" src="http://192.168.1.8/index.php/index/echobody">
</frameset>
<frame name="status" id="status" frameborder="1" scrolling="no" noresize="noresize" src="http://192.168.1.8/index.php/index/echostatus">
</frameset>
</html>
如果用redirect()直接调整过去,看到的页面是正常的。
对照html标记的说明,frameset好像是不能跟body一起用,我的html代码里面没有用body,难倒是一用load->view('sys/views'),codeigniter就自动给我加上了body标记了吗?
请各位大侠赐教! 本帖最后由 jeongee 于 2011-2-6 19:57 编辑
不会,你的视图文件应该是php后缀的,下面是ci加载视图文件的部分代码:
if ((bool) @ini_get('short_open_tag') === FALSE AND config_item('rewrite_short_tags') == TRUE)
{
echo eval('?>'.preg_replace("/;*\s*\?>/", "; ?>", str_replace('<?=', '<?php echo ', file_get_contents($_ci_path))));
}
else
{
include($_ci_path); // include() vs include_once() allows for multiple views with the same name
}
我要说明下frameset就是不需要body的,看下我的一个页面
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $webconfig['name'];?>-管理后台</title>
</head>
<frameset rows="30,*" cols="*" frameborder="no" border="0" framespacing="0">
<frame src="header" name="topFrame"id="topFrame" scrolling="no" noresize="noresize"/>
<frameset cols="162,*" frameborder="no" border="0" framespacing="0">
<frame src="menu" name="leftFrame" id="leftFrame" scrolling="yes" noresize="noresize"/>
<frame src="main" name="mainFrame" id="mainFrame" scrolling="auto"/>
</frameset>
</frameset>
<noframes>
<body>
</body>
</noframes>
</html>
2L版主,htm后缀的跟php后缀的有什么区别吗?
楼上的,我的跟你的没啥差别,只是删掉了<noframe>这点无用的代码。
我试试看用.php后缀的。 试了,换成是php后缀的,还是不行呀! 2L版主,能不能帮忙看看我的代码啥问题? 用谷歌浏览器的审核元素功能,发现不知道在什么时候,页面最前面已经被<body>。。。 这个和 frameset 无关,这是浏览器的事情,你的 CI 只管输出,而具体显示成什么样要由浏览器决定。 皇天不负有心人,追查了一天一夜,终于让我找到原因了:
用谷歌浏览器的审核元素功能,发现不知道在什么时候,页面最前面已经被<body>。。。
居然是config.php文件的问题!!!!
原始的config.php文件是GBK编码的,我修改成utf-8,然后,codeigniter系统就会在加载视图(甚至在加载控制器前)就发出了一个header命令,所以就造成了在load view时已经有了body,有了body标记,就跟frameset标记产生了冲突!
教训:codeigniter的config文件千万不要修改成utf-8编码!!!!!
可这样问题又出来了:我设置的一些变量里面肯定是有utf-8编码的中文字符的,如果config是gbk的,在我utf的页面里面显示只能是乱码了!!!
怎么解决,哪个大侠给个方案? ci有utf-8版本的没?:'(