js파일에 값을 넣기 또는 전달 할 수 없을까요? > 자유게시판

자유게시판

js파일에 값을 넣기 또는 전달 할 수 없을까요? 정보

js파일에 값을 넣기 또는 전달 할 수 없을까요?

본문

1.html?id=aaa

이렇게 접속했을시 js에 값을 넣을방법 또는 값을 전달 할 수 있을까요?

--------------------------------------------------------------------

1.html내용
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=euc-kr">
<title>title</title>
<script type="text/javascript" src="1.js"></script>
</head>
<body>
본문
</body>
</html>

--------------------------------------------------------------------

1.js 내용
<script type="text/javascript">
.....
.....
var id = aaa를 여기 받기
.....
.....
</script>

--------------------------------------------------------------------

1.html에 아래처럼 자바소스를 넣고하면 되는데 위와 같이 js파일을 불러서하니 안되네요.

<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=euc-kr">
<title>title</title>
<script type="text/javascript">
.....
.....
var id = aaa를 여기 받기
.....
.....
</script>
</head>
<body>
본문
</body>
</html>

추천
0
  • 복사

댓글 4개

1.js?id=aaa
이렇게 하고 웹프로그램이 js파일에서 작동 될수 있도록

환경 설정을 바꿔 주면 됩니다.

js 내용
<script type="text/javascript">
.....
.....
var id = <?=$_GET['aaa']?>;
.....
.....
</script>
불바람님 답글 감사합니다.
근데요
이렇게 하고 웹프로그램이 js파일에서 작동 될수 있도록 환경 설정을 바꿔 주면 됩니다.
이게 무슨 말씀인지요?
아파치 http.conf에 보면 다음이 있습니다.
<IfModule mime_module>

    AddType application/x-httpd-php .php .php4 .php3 .html .htm

끝에 .js 추가하시면 됩니다.
© SIRSOFT
현재 페이지 제일 처음으로