2011-01-29 15 views
2

私はcodeigniter 2.0を新しくインストールしましたが、外部のjavascriptファイルをリンクするのは苦労しています。ここで私が持っているものです。codeigniter external javascript

マイコントローラ:

<?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 */ 

マイビュー:

<!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> 

マイJavascriptを:

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

ディレクトリ構造:

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

わかりやすくするために、ここでは自分のパスに「http:// localhost ...」を使用しています。画像はロードされますが、javascriptではロードされません。私は間違って何をしていますか?

+0

あなたがアドレスバーにJavaScriptのURLを入力すると、スクリプトロードしていますか? – Pointy

+0

ああ、どのようなシステムのサーバー(どのOS)ですか?大文字小文字の混乱が起こる可能性はありますか? – Pointy

答えて

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

は次のようになります。

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

SRC、ないソース