| 
 | 
 
 
发表于 2012-8-12 00:55:11
|
显示全部楼层
 
 
 
 本帖最后由 wx2650 于 2012-8-12 00:56 编辑  
HTML复制代码  
<head>
<title>博客列表 </title>
<base href="http://127.0.0.1/Blog/" />
<link rel="stylesheet" type="text/css" href="style.css" />
    <meta http-equiv="Content-Type" content="text/html; charset=GBK" />
    <!-- CuFon: Enables smooth pretty custom font rendering. 100% SEO friendly. To disable, remove this section -->
    <script type="text/javascript" src="js/cufon-yui.js"></script>
    <script type="text/javascript" src="js/arial.js"></script>
    <script type="text/javascript" src="js/cuf_run.js"></script>
</head>
   复制代码 
 
如上 
可以看到head中还有很多js和css 
上面的JS写的都是相对路径,这个路径是相对于“http://127.0.0.1/Blog/" 来说的 
 
相当于 
 
<link rel="stylesheet" type="text/css" href="http://127.0.0.1/Blog/style.css" /> 
<script type="text/javascript" src="http://127.0.0.1/Blog/js/arial.js"></script> 
 
 
 
 
因此只要写一个 
<base href="<?php echo $base_url ?>" /> 
 
其他的图片或者JS就不用写 $base_url了 
 
 
  
你还可以新建一个视图来存储“<!DOCTYPE   ”到“</head>”之间的内容 
 
而后,每次新建一个视图时,就只要写 
 
<?php $this->load->view('header');?> 
<body> 
 
<!-- web content --> 
</body> 
</html> 
 
就可以了 
 
 
 
 
 |   
 
 
 
 |