테스트 사이트 - 개발 중인 베타 버전입니다

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>

댓글 작성

댓글을 작성하시려면 로그인이 필요합니다.

로그인하기

댓글 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 추가하시면 됩니다.
엑스엠엘님 감사합니다^^

게시판 목록

자유게시판

글쓰기

첫글

1개월 전
🐛 버그신고