开发者

codeigniter external javascript

I have a fresh install of codeigniter 2.0, and I'm having a hard time linking external javascript files. Here's what I have:

My controller:

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Welcome extends CI_Controller {

    function __construct()
    {
        parent::__construct();
    }

    function index()
    {
        $this->load->view('welcome_message');
    }
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */

My view:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Welcome to CodeIgniter</title>
<script source="http://localhost/JS/javascript.js" type="text/javascript"></script>
</head>
<body>

 <A HREF="javascript:a_message()">Click for a message..</A>
<img src="http://localhost/images/apache_pb.png" >
</body>
</html>

My Javascript:

function a_message(){ alert('yay'); }

Directory structure:

htdocs
    application
    images
        apache_pb.png
    JS
        javascript.js
    system
    user_guide
    xampp
    index.php
    license.txt
    Thumbs.db

I'm using "http://localhost..." in my paths here for simplicity. The image loa开发者_运维技巧ds, but the javascript doesn't. What am I doing wrong?


<script source="http://localhost/JS/javascript.js" type="text/javascript"></script>

should be:

<script src="http://localhost/JS/javascript.js" type="text/javascript"></script>

src, not source

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜