๋ชฉ์ฐจ
1. 2023.11.29(์)
โ โ โ Javascript ๊ฐ์ ๋ฐ ๊ธฐ๋ณธ๋ฌธ๋ฒ โ โ โ
โ ๊ฐ์
์ปดํ์ผ ๊ณผ์ ์ด ํ์์๊ฑฐ๋ ์ฒ๋ฆฌ ๊ณผ์ ์ด ์ ์ ํ๋ก๊ทธ๋จ์ ์ ๋ฆฌํ ์คํฌ๋ฆฝํธ ์ธ์ด๋ก
๋ค๋ฅธ ์ด์ด์ ๋นํด ์์ค ์ฝ๋์ ์์ ๋ฐ ์ ์ง๋ณด์๊ฐ ๊ฐํธํ ํธ์ด๋ค.
HTML ์ฝ๋ฉ์์ ์๋ฐ์คํฌ๋ฆฝํธ ์์ค์ ๋ช
์๋ง์ผ๋ก ์น ๋ธ๋ผ์ฐ์ ๊ฐ ์๋ ์คํํ๋ค.
์๋ฐ์คํฌ๋ฆฝํธ๋ ์น ํ์ด์ง์์ ๊ฐ์ฅ ๋ง์ด ์ฌ์ฉ๋๋ ์คํฌ๋ฆฝํ
(Scripting)์ธ์ด๋ก
์คํฌ๋ฆฝํ
(Scripting)์ธ์ด๋ ํฌ๊ฒ ๋๋๋ฉด
์๋ฐ์คํฌ๋ฆฝํธ๋ DHTML, Visual Basic ๋ฑ๊ณผ ๊ฐ์ ๋ธ๋ผ์ฐ์ ์คํฌ๋ฆฝํ
(Browser Scripting),
JSP, ASP, PHP ์ ๊ฐ์ ์๋ฒ ์คํฌ๋ฆฝํ
(Server Scripting) ์ธ์ด๋ก ๊ตฌ๋ถํ ์ ์๋ค.
ํนํ ์๋ฐ์คํฌ๋ฆฝํธ๋ ์๋ฒ ์คํฌ๋ฆฝํ
(Sever Scripting) ์ธ์ด์ ์ฐ๋๋์ด
์
๋ ฅ๋์ ์
๋ ฅํ ๊ฐ์ด ์ ๋๋ก ๋ ๊ฐ์ธ์ง์ ์ฌ๋ถ ๋ฑ์ ์ฒดํฌํ๋
**์ํธ์์ฉ(Interactive)**์ ์์์ ์น ํ์ด์ง์ **๋์ (Dynamic)**์ธ ํจ๊ณผ ๋ฑ์
์ ์ฉํ๋ ๋ถ๋ถ์ ์ฌ์ฉ๋๋ฉฐ ๊ทธ ๋ฐ์๋ ๋ง์ ๊ธฐ๋ฅ์ ์ฌ์ฉ์๊ฐ ์ถ๊ฐํ์ฌ
์ฌ์ฉํ๋ ๋งค์ฐ ์ค์ํ ์์๋ผ๊ณ ํ ์ ์๋ค.
โป Javascript ๋ HTML ๋ฌธ์์
์ํธ์์ฉ(Interactive)ํ๋ ์์์ ๋์ (Dynamic)์ธ ์์๋ฅผ
์ถ๊ฐํ๊ธฐ ์ํด ์ฌ์ฉํ๋ ์ธ์ด์ด๋ค.
โ HTML ๋ฌธ์์ Javascript ์ถ๊ฐ
1. Inline Javascript(HTML Tag ์์ ์ง์ ํ์ฌ ์ฌ์ฉ)
<a href="javascript:location.href='http://www.com'">๋ค์ด๋ฒ</a>
2. Embeded Javascript์ Script Block(Script Block ์์ ์ผ๊ด ์ง์ ํ์ฌ ์ฌ์ฉ)
<script type="text/javascript">
document.write("์ด์ฉ๊ตฌ ์ ์ฉ๊ตฌ");
</script>
โป document ๋ HTML ๋ฌธ์ Object ๋ฅผ ์๋ฏธํ๋ฉฐ
write() ํจ์๋ document Object ์ ์ถ๋ ฅํ๋ ๊ฒ์ ์๋ฏธํ๋ค.
3. Linked Javascript(์ธ๋ถ ํ์ผ์ ๋งํฌํ์ฌ ์ฌ๋ฌ ๊ฐ์ ํ์ผ์ ์ผ๊ด ์ง์ ํ์ฌ ์ฌ์ฉ)
<script type="text/javascript" src="url ๊ฒฝ๋ก์ง์ "></script>
โ Javascript ์ ๊ธฐ์ด ๊ตฌ๋ฌธ๊ณผ ์ฃผ์ ๋ฐ์ดํฐํ์
1. Javascript ์ ์ฃผ์๋ฌธ(comment)
๋ผ์ธ ๋จ์ ์ฃผ์๋ฌธ์ ๊ฒฝ์ฐ 2๊ฐ์ slash(<//>)๋ฅผ ์ฃผ์๋ฌธ ์์ ๋ถ์ฌ ์ฌ์ฉํ๊ณ
๋ธ๋ญ ๋จ์ ์ฃผ์๋ฌธ์ ๊ฒฝ์ฐ </* ์ฌ๋ฌ์ค ์ฃผ์*/>๊ณผ ๊ฐ์ด ์ฌ์ฉํ๋ค.
2. Javascript ์ ๋ช ๋ น line ์ฒ๋ฆฌ
2๊ฐ ์ด์์ script ๋ช
๋ น์ ์ฌ์ฉํ ๊ฒฝ์ฐ<;(์ธ๋ฏธ์ฝ๋ก )>์ผ๋ก ๊ตฌ๋ถํด ์ค ์ ์๋๋ก ํ๋ค.
(๊ฐํ ์ญ์ ๊ตฌ๋ถ์์ ์ญํ ์ ์ํํ์ง๋ง <;>์ ๋ถ์ฌ์ ์ฌ์ฉํ ์ ์๋๋ก ํ๋ค.)
3. Javascript ์ ์ฌ์ฉ๋๋ ์ฃผ์ ๋ฐ์ดํฐํ์
์ ์: 0~9์ฌ์ด์ ๊ฐ ์๋ฆฟ์์ ํด๋นํ๋ ์์์ ์์
๋ฐ์ดํ ์์ ๋ฃ์ง ์๋๋ค.
์ค์: 0~9์ฌ์ด์ ๊ฐ ์๋ฆฟ์์ ํด๋นํ๋ ์์์ ์์๋ฅผ ํฌํจํ ๋ถ๋ ์์.
๋ฐ์ดํ ์์ ๋ฃ์ง ์๋๋ค.
Boolean(true or false): true ์ false ์ ๋
ผ๋ฆฌํ
String(๋ฌธ์์ด): ์ฌ์ฉํ ์ ์๋ ๋ชจ๋ ๋ฌธ์๋ฅผ ์๋ฏธํ๋ฉฐ
๋ฐ์ดํ(<" ">)์์ ๋ฃ์ด์ ์ฌ์ฉํ๋ค.
โ Javascript ๋ฐฐ์ด
1. 1์ฐจ์ ๋ฐฐ์ด ์ ์ธ - ํฌ๊ธฐ ์ง์ ์์ด ์ ์ธ ๊ฐ๋ฅ
var ๋ณ์๋ช
= enw Array();
๋ณ์๋ช
[0] = ๊ฐ1;
๋ณ์๋ช
[1] = ๊ฐ2;
๋ณ์๋ช
[2] = ๊ฐ3;
...
var ๋ณ์๋ช
= new Array(๊ฐ1, ๊ฐ2, ๊ฐ3, ...);
var ๋ณ์๋ช
= [๊ฐ1, ๊ฐ2, ๊ฐ3, ...];
2. 2์ฐจ์ ๋ฐฐ์ด ์ ์ธ -ํฌ๊ธฐ ์ง์ ์์ด ์ ์ธ ๊ฐ๋ฅ
var ๋ณ์๋ช
= new Array();
๋ณ์๋ช
[0] = new Array();
๋ณ์๋ช
[1] = new Array();
๋ณ์๋ช
[2] = new Array();
...
๋ณ์๋ช
[0][0] = ๊ฐ1;
๋ณ์๋ช
[0][1] = ๊ฐ2;
๋ณ์๋ช
[0][2] = ๊ฐ3;
...
var ๋ณ์๋ช
= new Array(new Array(), new Array(), new Array(), ...);
๋ณ์๋ช
[0][0] = ๊ฐ1;
๋ณ์๋ช
[0][1] = ๊ฐ2;
๋ณ์๋ช
[0][2] = ๊ฐ3;
...
var ๋ณ์๋ช
[[๊ฐ1, ๊ฐ2, ๊ฐ3, ... ], [], []];
3. ๋ฌธ์์ด.split(๊ตฌ๋ถ์)
var str = "1 2 3 4 5";
var arr = str.split(" "); //-- 1์ฐจ์ ๋ฐฐ์ด ๋ฐํ
for (var n=0; n<arr.length; n++)
{
document.getElementById("result").value += arr[n] + " ";
}
//--==>> 1 2 3 4 5
F_WebApp03
ใด C:\WebStudy\WebApp03\WebContent
ใดใดTest001.html_์๋ฐ์คํฌ๋ฆฝํธ ์ฝ๋ ์ ์ธ, ๋ํ๋จผํธ์ ์คํฌ๋ฆฝํธ๋ก ์ถ๋ ฅ(document.write("์ถ๋ ฅ๋ด์ฉ"))

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Test001.html</title>
</head>
<body>
<!-- ๋ด์ฉ ํ์ธ -->
<script type="text/javascript">
//-- ์๋ฐ์คํฌ๋ฆฝํธ ์์ค ์ฝ๋๊ฐ ์์๋๋ค๋ ์ ์ธ
/* 2023๋
11์์ ๋ */
//window.document.๊ฐ์ฒด
/*----- ๋ธ๋ผ์ฐ์ ์ ์ฐฝ
------- ๋ฌธ์
----- ๊ฐ์ฒด
(์ฌ์ค ๋ธ๋ผ์ฐ์ ์ฐฝ, ๋ฌธ์ ๋ชจ๋ ๊ฐ์ฒด! ๊ฐ์ฒด์์ ๊ฐ์ฒด๋ฅผ ๋ถ๋ฅด๋ ๊ฒ) */
document.write("2023๋
11์์ ๋");
//-- ์ถ๋ ฅ์ ์ง์ํ๋ ์๋ฐ์คํฌ๋ฆฝํธ ๋ช
๋ น์ด
// ์ถ๋ ฅ ๋ด์ฉ: ๋ฌธ์์ด, ๋ณ์๋ช
, ์ฐ์ฐ๊ฒฐ๊ณผ
</script>
</body>
</html>
ใดใดTest002.html_document.write์ ๊ฐํ("<br>") ๋ฐ ํ๊ทธ ์ฝ์

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Test002.html</title>
</head>
<body>
<script type="text/javascript">
document.write("<h1>2023๋
11์์ด ์ ๋ฌด๋ ์์ ์์ ... </h1>");
// **.write์์ ํ๊ทธ์์ผ๋ก ํ
์คํธ๋ฅผ ๋ฃ์ด ์ถ๋ ฅ ๊ฐ๋ฅ**
document.write("์ด์ค์");
// **๊ทธ๋ฅ ํ
์คํธ ์ถ๋ ฅ์ผ๋ก๋ ๊ฐํ๋์ง ์์**
document.write("2023๋
11์์ด ์ ๋ฌด๋ ์์ ์์ ...");
document.write("์ด์ค์");
//--==>> 2023๋
11์์ด ์ ๋ฌด๋ ์์ ์์ ...์ด์ค์
document.write("<br>๊ฐ๊ธฐ ์กฐ์ฌํฉ์๋ค~!!!<br>");
document.write("๋ฌธ์ ํ");
//--==>> ๊ฐ๊ธฐ ์กฐ์ฌํฉ์๋ค~!!!
// ๋ฌธ์ ํ
// **๋๋์ํ๋ก ํ๊ทธ๋ฅผ ๊ฐ์ธ๋ ํํ ๊ฐ๋ฅ**
document.write("<h2>");
document.write("๊ธฐ์ด๋
์๋ค~!!!");
document.write("</h2>");
document.write("<h3>" + "ํ๋ค์ด๋ ์กฐ๊ธ๋ง ์ฐธ์๋ณด๊ฒ ๋ค" + "</h3>");
</script>
</body>
</html>
ใดใดTest003.html_javascript๋ body์ ์ถ๋ ฅ๋์ง ์์

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Test003.html</title>
<!-- javascript์ ์์น๋ title ๋ฐ์ด๊ฑฐ๋ body ์์์๋ ์คํ๋จ -->
<script type="text/javascript">
document.write("2023๋
11์์ด ์ ๋ฌด๋ ์ด๋๋ ");
</script>
</head>
<body>
<!-- body ์์ญ์๋ ์๋ฌด ๋ด์ฉ๋ ์กด์ฌํ์ง ์์ -->
</body>
</html>
ใดใดTest004.html_Linked Javascript(์ธ๋ถ ํ์ผ์ ๋งํฌ)

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Test004.html</title>
<script type="text/javascript" src="js/jsTest.js"></script>
</head>
<body>
<!--
ใjsTest.jsใ๋ผ๋ ํ์ผ์ ํธ์ถํ๋ ํ์์ ์ทจํ๊ณ ์๋ค.
ํธ์ถํ๋ ๋์ ํ์ผ์ ๊ฒฝ๋ก ํฌํจ ํ์ผ๋ช
์ src ์์ฑ์ ํตํด ๋ช
์ํ๊ฒ ๋๋ฉฐ
์ด ๋, ์๋ฐ์คํฌ๋ฆฝํธ ํ์ด๋ฅด์ด ํ์ฅ์๋ ๋ฐ๋์ ใ*.jsใ ์ด์ด์ผ ํ๋ค.
-->
</body>
</html>
ใดใด..js/jsTest.js


/**
* jsTest.js
*/
document.write("2023๋
11์์ด ์ ๋ฌด๋ ์ด๋๋ ...")
ใดใดTest005.html_Embeded Javascript(ํ์ผ ๋ด๋ถ ์ ์ธ)

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Test005.html</title>
<script type="text/javascript">
num1=10; // ๋ณ์ ์ ์ธ ๋ฐ ์ด๊ธฐํ -> var num1=10;
// (๋ณ์ ์ ์ธ ๊ณผ์ ์ด ํน๋ณํ ์กด์ฌํ์ง ์์)
document.write("num1=");// ๋จ์ ๋ฌธ์์ด ์ถ๋ ฅ -> "num1="
document.write(num1); // write() ํจ์์ num1 ์ด๋ผ๋ ๋ณ์๋ฅผ ๋๊ฒจ์ฃผ๋ ์ํฉ
// -> num1 ์ ๋ด๊ฒจ์๋ 10์ด ์ถ๋ ฅ
document.write("num1";) // ์ด ๊ตฌ๋ถ๊ณผ ๋น๊ต ๊ฐ๋ฅ~!!!
</script>
</head>
<body>
</body>
</html>
ใดใดTest006.html_document.write()์์์ ๊ฐํ("<br>")

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Test006.html</title>
<script type="text/javascript">
/* **
- .write์์์ ๊ฐํ์ '\n'(X) -> '<br>'(O)
- num1 ์ด๋ผ๋ ๋ณ์๋ ์ ์๋ฅผ ๋ด์ ๋ณ์์ด๋, ๋ฌธ์๋ ๋ด์ ์ ์์
** */
num1=10; // ๋ณ์ num1 ์ 10 ๋์
document.write("num1="); // ๋ฌธ์์ด ์ถ๋ ฅ
document.write(num1); // ๋ณ์ ์ถ๋ ฅ
num1=100; // ๋ณ์ num1 ์ 100 ๋์
(๊ธฐ์กด 10์ใ
๋ฎ์ด์ฐ๊ธฐ)
//document.write("\n num1="); // ๋ฌธ์์ด ์ถ๋ ฅ -> ๊ฐํ ์๋จ~!!! check~!!!
document.write("<br>num1="); // ๋ผ์ธ ์คํต(๊ฐํ)์ ์ํด ์ฌ์ฉํ <br>
document.write(num1); // ๋ณ์ ์ถ๋ ฅ
num1="2023๋
11์์ด ์ ๋ฌด๋ ์ด๋๋ ...";// ๋ณ์ num1์ ๋ฌธ์์ด ๋์
document.write("<br>num1=");
document.write(num1);
num2=200; // ๋ณ์ num2 ๊ตฌ์ฑ
num1= num2; // ๋ณ์ num1์ num2 ๋์
document.write("<br>num1=");
document.write(num1);
</script>
</head>
<body>
</body>
</html>
ใดใดTest007.html_๋ณ์์ ์ธ์์์ ์๋ฃํ(var) ์ง์ ์์ด๋ ์คํ์์ ๋ฌธ์ ์์


<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Test007.html</title>
<script type="text/javascript">
/* document.write("์๋ฌ ์ฐพ๋ ๋ฒ); */
num1=10;
var num2; //** ์์ด๋ ์๋ฌ๋์ง ์์
num2=20;
var num3=30;
document.write("num1=" + num1);
document.write("<br>num2="+num2);
document.write("<br>num3=");
document.write(num3);
</script>
</head>
<body>
</body>
</html>
ใดใดTest008.html_๋๋๊ธฐ(/) ์์ซ์ ๊น์ง, ๋๋จธ์ง(%) ๊ฐ ์์ผ๋ฉด ๋ฐ์ฌ๋ฆผ๋จ

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Test008.html</title>
<script type="text/javascript">
num1=7;
num2=3;
res=num1 + num2; // ๋ํ๊ธฐ(๋ง์
์ฐ์ฐ)
document.write("num1 + num2 = ");
document.write(res);
res=num1 - num2; // ๋นผ๊ธฐ(๋บ์
์ฐ์ฐ)
document.write("<br>num1 - num2 = ");
document.write(res);
res=num1 * num2; // ๊ณฑํ๊ธฐ(๊ณฑ์
์ฐ์ฐ)
document.write("<br>num1 * num2 = ");
document.write(res);
res=num1 / num2; // ๋๋๊ธฐ(๋๋์
์ฐ์ฐ) check~!!!
document.write("<br>num1 / num2 = ");//-- ๊ฒฐ๊ณผ๊ฐ์ผ๋ก ๋ฐํ๋๋ ๋ฐ์ดํฐ์ ํํ ๊ด์ฐฐ
document.write(res);
res=num1 % num2; // ๋๋จธ์ง(๋๋์
์ฐ์ฐ) check~!!!
document.write("<br>num1 % num2 = ");// **๋๋จธ์ง ์ฌ๋ฆผ๋จ**
document.write(res);
</script>
</head>
<body>
</body>
</html>
ใดใดTest009.html_ ++, --

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Test009.html</title>
</head>
<script type="text/javascript">
/* **++,-- ๊ฐ๋ฅ** */
num1 = 7;
num2 = 3;
document.write("์๋์ num1: ");
document.write(num1);
++num1;
document.write("<br>์ฒซ ๋ฒ์งธ ++num1: ");
document.write(num1);
++num1;
document.write("<br>๋ ๋ฒ์งธ ++num1: ");
document.write(num1);
document.write("<br><br>์๋์ num2: ");
document.write(num2);
--num2;
document.write("<br><br>์ฒซ ๋ฒ์งธ --num2: ");
document.write(num2);
--num2;
document.write("<br>๋ ๋ฒ์งธ --num2: ");
document.write(num2);
</script>
<body>
</body>
</html>
ใดใดTest010.html_ ๋ณตํฉ๋์ ์ฐ์ฐ์(+=,-=,*=,/=,%=)

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Test010.html</title>
<script type="text/javascript">
/* **๋ณตํฉ๋์
์ฐ์ฐ์์์๋ ํผ์ฐ์ฐ์์ ๊ฐ์ด ๋ฐ๋** */
num1=7;
num2=3;
num1+=num2;
document.write("num1 += num2 -> ");
document.write(num1);
num1=7;
num2=3;
num1-=num2;
document.write("<br>num1 -= num2 -> ");
document.write(num1);
num1=7;
num2=3;
num1*=num2;
document.write("<br>num1 *= num2 -> ");
document.write(num1);
num1=7;
num2=3;
num1/=num2;
document.write("<br>num1 /= num2 -> ");
document.write(num1);
num1=7;
num2=3;
num1%=num2;
document.write("<br>num1 %= num2 -> ");
document.write(num1);
</script>
</head>
<body>
</body>
</html>
ใดใดTest011.html_๊ด๊ณ์ฐ์ฐ์, ์ผํญ์ฐ์ฐ์, ์กฐ๊ฑด์ฐ์ฐ์

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Test011.html</title>
<script type="text/javascript">
/* **๊ด๊ณ์ฐ์ฐ์ -> true or false ๋ฐํ** */
/* **์ผํญ์ฐ์ฐ์, ์กฐ๊ฑด์ฐ์ฐ์ ๊ฐ๋ฅ** */
num1=7;
num2=3;
res=(num1==num2);
document.write("num1 == num2 -> ");
document.write(res);
res=(num1>=num2);
document.write("<br>num1>=num2 -> ");
document.write(res);
res=(num1<=num2);
document.write("<br>num1<=num2 -> ");
document.write(res);
//----------------------------------------------
document.write("<br><br><br><br>");
res = (num1<10 && num2<10);
document.write("<br>num1<10 && num2<10 -> ");
document.write(res);
res = (num1>10 && num2>10);
document.write("<br>num1>10 && num2>10 -> ");
document.write(res);
res = (num1>10 && num2>10);
document.write("<br>num1>10 || num2>10 -> ");
document.write(res);
res = (num1>10 || num2<10);
document.write("<br>num1>10 || num2<10 -> ");
document.write(res);
res = !(num1 == num2);
document.write("<br>!(num1==num2) -> ");
document.write(res);
//----------------------------------------------
document.write("<br><br><br><br>");
human = "์ฐ์ธ";
res = (human == "์ฐ์ธ")?"์ฌ๋":"์ฐ์ ";
document.write("<br>res= ");
document.write(res);
human="์น๊ตฌ";
res=(human=="์ฐ์ธ")?"์ฌ๋":"์ฐ์ ";
document.write("<br>res= ");
document.write(res);
</script>
</head>
<body>
</body>
</html>
ใดใดTest012.html_alter ํ๊ทธ, ๋ด๋ถ-์ธ๋ถ ์คํฌ๋ฆฝํธ ๋ด์ฉ ๊ณต์ ํจ, js ์์น์ ๋ฐ๋ผ ์คํ์ฌ๋ถ ๋ฌ๋ผ์ง ์ ์์

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Test012.html</title>
<script type="text/javascript">
/* **
-.write์์๋ ํ๊ทธ ์ธ์ ๋๋, alert์์๋ ํ๊ทธ ์ธ์ ๋์ง์์
-.alter๋ ์ฝ๋์์์ ์๊ด์์ด ๋จผ์ ์ฒ๋ฆฌ๋จ
- javascript ๊ฐ์์ ์๊ด์์ด ๋ชจ๋ ์คํ๋จ
- ๋ด๋ถ script์ ์ธ๋ถ script๋ ๋ด์ฉ์ ๊ณต์ ํจ
- javascript์ ์์น์ ๋ฐ๋ผ์ ์คํ์ฌ๋ถ๊ฐ ๋ฌ๋ผ์ง ์ ์์
- ์๋ฌธ์ ์์์ด๋ฆ() ->
- ๋๋ฌธ์ ์์์ด๋ฆ() -> ์๋ฐ์คํฌ๋ฆฝํธ ์์ฑ์ํจ์ ํธ์ถ
** */
//alert(message); //** ๊ฒฝ๊ณ ์ฐฝ
//--==>> ์๋ฌด๊ฒ๋ ๋จ์ง ์์(์ค๋ฅ๊ฐ ์๊ธฐ ๋๋ฌธ์)
message="<h1>Hello~!!</h1>";
//alert(message); //** ๊ฒฝ๊ณ ์ฐฝ
//--==>> ๊ฒฝ๊ณ ์ฐฝ์ ๋ฒํผ ์ ํํ, document ์ถ๋ ฅ๋จ
document.write(message);
alert(message); //** ๊ฒฝ๊ณ ์ฐฝ
</script>
<script type="text/javascript" src="js/alertTest.js"></script>
<script type="text/javascript">
// Date ๋ด์ฅ ๊ฐ์ฒด: ํ์ฌ ์์คํ
์ ๋ ์ง์ ์๊ฐ
// var dt = Date().toString();
var dt=String(Date());
document.write(dt);
</script>
</head>
<body>
</body>
</html>
ใดใด../js/alertTest.js
/**
* alertTest.js
*/
alert(message);
ใดใดTest013.html_ํจ์๋ ํธ์ถํด์ผ ์คํ๋จ/ document.onload ์ด๋ฒคํธ ๋ฑ๋ก

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Test013.html</title>
<script type="text/javascript">
/* **- ํจ์๋ ํธ์ถํด์ผ ์คํ๋จ** */
*
*/
/* ์ด๋ฒคํธ ๋ฑ๋ก ๋ฐฉ๋ฒ โก */
/* document.onload = ํ์, ๋์, ๊ธฐ๋ฅ */
document.onload = windowOnload();
function windowOnload()
{
alert("๊ฒฝ๊ณ ์ฐฝ~!!!");
}
</script>
</head>
<!-- ์ด๋ฒคํธ ๋ฑ๋ก ๋ฐฉ๋ฒ โ -->
<!-- <body onload="windowOnload()"> -->
<body>
<h1>์ ํ์ธ</h1>
<h2>๋ฐฐ๋ถ๋ฅด๋ค~!!!</h2>
<h3>์ง๊ฒ ๋จน์๋ค~!!!</h3>
</body>
</html>
ใดใดTest014.html_ํจ์ ๋ฑ๋ก


<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Test014.html</title>
<script type="text/javascript">
var msg="2023๋
11์์ด ์ ๋ฌด๋ ์ด๋๋ ...";
function buttonOnclick1()
{
// ํ
์คํธ
alert("์ฒซ ๋ฒ์งธ ๋ฒํผ ํด๋ฆญ ํ์ธ~!!!");
}
function buttonOnclick2()
{
// ํ
์คํธ
alert("๋ ๋ฒ์งธ ๋ฒํผ ํด๋ฆญ ํ์ธ~!!!");
}
</script>
</head>
<body>
<input type="button" id="btn01" value="Button1" onclick="buttonOnclick1()"><br>
<input type="button" id="btn02" value="Button2" onclick="buttonOnclick2()"><br>
</body>
</html>
'๐ ๋ฐฐ์ฐ๊ณ ์ตํ๊ธฐ + > Web' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
| (70)[Web]5์ผ์ฐจ: ((Javascript))F_WebApp03>Test022~025 (2) | 2023.12.01 |
|---|---|
| (69)[Web]4์ผ์ฐจ: ((Javascript)) F_WebApp03>Test015~021 (1) | 2023.12.01 |
| (68)[Web]3์ผ์ฐจ: ((CSS)) F_WebApp02>Test005~020 (4) | 2023.11.29 |
| (66)[Web]2์ผ์ฐจ: CSS ๊ฐ์ / โ CSS โ / F_WebApp02>Test001~004 (0) | 2023.11.28 |
| (66)[Web]2์ผ์ฐจ: ((HTML)) F_WebApp01>Test005~023 (1) | 2023.11.28 |