2011-01-29 4 views
2

나는 codeigniter 2.0을 새로 설치했으며 외부 자바 스크립트 파일을 연결하는 데 어려움을 겪고 있습니다. 여기에 내가 가진 무엇 :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> 

내 자바 스크립트 :

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 ..."를 사용하고 있습니다. 이미지가로드되지만 자바 스크립트는로드되지 않습니다. 내가 도대체 ​​뭘 잘못하고있는 겁니까?

+0

하면 주소 표시 줄에 자바 스크립트 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하지 소스