生成script标签
来源:互联网 发布:好吃的零食求推荐知乎 编辑:程序博客网 时间:2024/04/30 08:57
在application/helpers/MY_html_helper.php中编写
// ------------------------------------------------------------------------
/**
* scriptSrc
*
* Generates an <script /> element
*
* @access public
* @param mixed
* @return string
*/
if ( ! function_exists('scriptSrc'))
{
function scriptSrc($src = '', $index_page = FALSE)
{
if ( ! is_array($src) )
{
$src = array('src' => $src);
}
$html = '<script ';
foreach ($src as $k=>$v)
{
if ($k == 'src' AND strpos($v, '://') === FALSE)
{
$CI =& get_instance();
if ($index_page === TRUE)
{
$html .= ' src="'.$CI->config->site_url($v).'"';
}
else
{
$html .= ' src="'.$CI->config->slash_item('base_url').$v.'"';
}
}
else
{
$html .= " $k=\"$v\"";
}
}
$html .= ' type="text/javascript"></script>';
return $html;
}
}
---------
默认,不启用html,必须在autoload.php中启用html
----------
使用方式:<?php echo scriptSrc('/a/scripts/index.js'); ?>
生成源代码:
<script src="http://www.edm.q//a/scripts/index.js" type="text/javascript"></script>
- 生成script标签
- script标签
- <script>标签
- script标签
- script标签
- Script标签的识别
- Script标签不能简写
- 双向Script 标签通信
- JavaScript的<script> 标签
- HTML <script> 标签
- Script标签的属性
- <script>标签说明
- <script>标签书写位置
- html标签之<script>
- <script>标签的问题
- <script>标签和属性
- JSP中的Script标签
- javascript之<script>标签
- CodeIgniter用后笔记1
- windows iis 安装php
- filezilla server ftp受到攻击处理
- 使用controllers子目录时默认页面处理
- iis的fastcgi路径
- 生成script标签
- 一个密码加密方案
- 使用windows的bat删除目录下所有的.svn文件夹
- 为每一个网站的文件夹建立一个index.html
- php的mysqli支持如果未启用,数据库设置使用mysqli时将造成页面空白
- $this->uri->segment(4, \'\')竟然没有解码还原
- 感觉table类有点那个了
- 仓促的为ic配置了一下编辑器cke和ckf
- 从input对象获取form对象