1

我的项目正在使用 Bootstrap 和 Codeigniter 的组合。我无法访问外部 javascript 文件中的函数。在 Firefox 中使用 firebug 我可以看到这些外部脚本已加载。外部 css 文件工作正常。请注意 jquery 可以工作,但我怀疑这是因为 jquery.js 文件包含在目录 assets/js/jquery.js 中的 Bootstrap/Codeigniter 框架中

这是我在每个 Codeigniter 视图中的标头代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">

    <!-- Fav and touch icons -->
    <link rel="apple-touch-icon-precomposed" sizes="144x144" href="/img/icons/apple-touch-icon-144-precomposed.png">
    <link rel="apple-touch-icon-precomposed" sizes="114x114" href="/img/icons/apple-touch-icon-114-precomposed.png">
    <link rel="apple-touch-icon-precomposed" sizes="72x72" href="/img/icons/apple-touch-icon-72-precomposed.png">
    <link rel="apple-touch-icon-precomposed" href="/img/icons/apple-touch-icon-57-precomposed.png">
    <link rel="shortcut icon" href="/img/icons/favicon.png">

    <title>Sample Website</title>

    <!-- Bootstrap core CSS -->
    <link href="/dist/css/bootstrap.css" rel="stylesheet">

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="../../assets/js/html5shiv.js"></script>
      <script src="../../assets/js/respond.min.js"></script>
    <![endif]-->

    <!-- Custom styles for this template -->
    <link href="/css/theme.css" rel="stylesheet">
    <link href="/css/carousel.css" rel="stylesheet">

    <!-- styles custom to our site -->
    <link href="/css/style.css" rel="stylesheet">

    <link href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" rel="stylesheet">
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
    <script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>        
    <script type="text/javascript" src="js/jquery.cookie.js"></script>   

</head>
4

1 回答 1

0

尝试在 url 之前添加 base_url:

<script type="text/javascript" src="<?= base_url();?>js/jquery.cookie.js"></script>
于 2013-09-26T17:04:55.993 回答