.ﺩﻮﺷﯽﻣ ﺝﺭﺩ </script>
ﻭ <script>
ﯼﺎﻫﮓﺗ ﻦﯿﺑ
<script>
document.getElementById("demo").innerHTML = "My First JavaScript";
</script>
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript in Body</h2>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML = "My First JavaScript";
</script>
</body>
</html>
<script; type="text/javascript">.
:ﺪﻨﻨﮐ ﻩﺩﺎﻔﺘﺳﺍ ﻉﻮﻧ ﯽﮔﮋﯾﻭ ﮏﯾ ﺯﺍ ﺖﺳﺍ ﻦﮑﻤﻣ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﯽﻤﯾﺪﻗ ﯼﺎﻫﻪﻧﻮﻤﻧ
.ﺩﺮﮐ ﺍﺮﺟﺍ "ﯽﻧﺍﻮﺧﺮﻓ" ﻡﺎﮕﻨﻫ ﺍﺭ ﻥﺁ ﻥﺍﻮﺗﯽﻣ ﻪﮐ ﺖﺳﺍ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﺪﮐ ﺯﺍ ﯽﮐﻮﻠﺑ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﺩﺮﮑﻠﻤﻋ<"code class="w
.ﺪﻨﮐﯽﻣ ﮏﯿﻠﮐ ﻪﻤﮐﺩ ﮏﯾ ﯼﻭﺭ ﺮﺑﺭﺎﮐ ﻪﮐ ﯽﻧﺎﻣﺯ ﺪﻨﻧﺎﻣ ،ﺩﺮﮐ ﯽﻧﺍﻮﺧﺍﺮﻓ ﺍﺭ ﻊﺑﺎﺗ ﮏﯾ ﻥﺍﻮﺗﯽﻣ ،ﺪﻫﺩﯽﻣ ﺥﺭ ﺩﺍﺪﯾﻭﺭ ﮏ
.ﺖﺧﻮﻣﺁ ﺪﯿﻫﺍﻮﺧ ﺎﻫﺩﺍﺪﯾﻭﺭ ﻭ ﺎﻫﺩﺮﮑﻠﻤﻋ ﺩﺭﻮﻣ ﺭﺩ ﯼﺮﺘﺸﯿﺑ ﺕﺎﻋﻼﻃﺍ ﯼﺪﻌﺑ ﯼﺎﻫ ﻞﺼﻓ ﺭﺩ
.ﺪﯿﻫﺩ ﺭﺍﺮﻗ HTML ﺪﻨﺳ ﮏﯾ ﺭﺩ ﺍﺭ ﺖﭙﯾﺮﮑﺳﺍ ﺩﺍﺪﻌﺗ ﺮﻫ ﺪﯿﻧﺍﻮﺗ ﯽﻣ ﺎﻤﺷ
ﻭﺩ ﺮﻫ ﺭﺩ ﺎﯾ ،ﺩﺍﺩ ﺭﺍﺮﻗ HTML ﻪﺤﻔﺻ ﮏﯾ <head>
ﺶﺨﺑ ﺭﺩ ﺎﯾ <body>
.ﺖﺳﺍ ﻩﺪﺷ ﻩﺩﺍﺩ ﺭﺍﺮﻗ <head>
ﺶﺨﺑ ﺭﺩ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﺩﺮﮑﻠﻤﻋ<"code class="w3-codespan
:ﺩﻮﺷ ﯽﻣ ﯽﻧﺍﻮﺧﺍﺮﻓ ﻊﺑﺎﺗ ،ﻪﻤﮐﺩ ﮏﯾ ﯼﻭﺭ ﮏﯿﻠﮐ ﺎﺑ
<!DOCTYPE html>
<html>
<head>
<script>
function myFunction() {
document.getElementById("demo").innerHTML = "Paragraph changed.";
}
</script>
</head>
<body>
<h2>Demo JavaScript in Head</h2>
<p id="demo">A Paragraph</p>
<button type="button" onclick="myFunction()">Try
it</button>
</body>
</html>
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<head>
<script>
function myFunction() {
document.getElementById("demo").innerHTML = "Paragraph changed.";
}
</script>
</head>
<body>
<h2>Demo JavaScript in Head</h2>
<p id="demo">A Paragraph.</p>
<button type="button" onclick="myFunction()">Try it</button>
</body>
</html>
.ﺖﺳﺍ ﻩﺪﺷ ﻩﺩﺍﺩ ﺭﺍﺮﻗ HTML ﻪﺤﻔﺻ ﮏﯾ <body>
ﺶﺨﺑ ﺭﺩ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﺩﺮﮑﻠﻤﻋ<"code class
:ﺩﻮﺷ ﯽﻣ ﯽﻧﺍﻮﺧﺍﺮﻓ ﻊﺑﺎﺗ ،ﻪﻤﮐﺩ ﮏﯾ ﯼﻭﺭ ﮏﯿﻠﮐ ﺎﺑ
<!DOCTYPE html>
<html>
<body>
<h2>Demo JavaScript in Body</h2>
<p id="demo">A Paragraph</p>
<button type="button" onclick="myFunction()">Try
it</button>
<script>
function myFunction() {
document.getElementById("demo").innerHTML = "Paragraph changed.";
}
</script>
</body>
</html>
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h2>Demo JavaScript in Body</h2>
<p id="demo">A Paragraph.</p>
<button type="button" onclick="myFunction()">Try it</button>
<script>
function myFunction() {
document.getElementById("demo").innerHTML = "Paragraph changed.";
}
</script>
</body>
</html>
ﺪﺸﺨﺑ ﯽﻣ ﺩﻮﺒﻬﺑ ﺍﺭ ﺮﮕﺸﯾﺎﻤﻧ <body> ﺮﺼﻨﻋ ﻦﯿﯾﺎﭘ ﺭﺩ ﺎﻫ ﺖﭙﯾﺮﮑﺳﺍ ﻥﺩﺍﺩ ﺭﺍﺮﻗ
:ﺩﺍﺩ ﺭﺍﺮﻗ ﺰﯿﻧ ﯽﺟﺭﺎﺧ ﯼﺎﻫ ﻞﯾﺎﻓ ﺭﺩ ﻥﺍﻮﺗ ﯽﻣ ﺍﺭ ﺎﻫ ﺖﭙﯾﺮﮑﺳﺍ
function myFunction() {
document.getElementById("demo").innerHTML = "Paragraph changed.";
}
.ﺩﻮﺷ ﻩﺩﺎﻔﺘﺳﺍ ﻒﻠﺘﺨﻣ ﺏﻭ ﺕﺎﺤﻔﺻ ﺯﺍ ﯼﺭﺎﯿﺴﺑ ﺭﺩ ﻪﺑﺎﺸﻣ ﯼﺎﻫﺪﮐ ﻪﮐ ﺪﻨﺘﺴﻫ ﯼﺩﺮﺑﺭﺎﮐ ﯽﻧﺎﻣﺯ ﯽﺟﺭﺎﺧ ﯼﺎﻫ ﺖﭙﯾﺮﮑﺳﺍ
.ﺪﻨﺘﺴﻫ .js ﻞﯾﺎﻓ ﺪﻧﻮﺴﭘ ﯼﺍﺭﺍﺩ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﯼﺎﻫ ﻞﯾﺎﻓ
.ﺪﯿﻫﺩ ﺭﺍﺮﻗ code class="w3-codespan">src (source)> ﯽﮔﮋﯾﻭ ﺭﺩ ﺍﺭ ﺖﭙﯾﺮﮑﺳﺍ ﻞﯾﺎﻓ ﻡﺎﻧ ،ﯽﺟﺭﺎﺧ ﺖﭙﯾﺮﮑﺳﺍ ﮏﯾ ﺯﺍ ﻩﺩﺎﻔﺘﺳﺍ ﯼﺍ
<script src="myScript.js"></script>
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h2>Demo External JavaScript</h2>
<p id="demo">A Paragraph.</p>
<button type="button" onclick="myFunction()">Try it</button>
<p>This example links to "myScript.js".</p>
<p>(myFunction is stored in "myScript.js")</p>
<script src="myScript.js"></script>
</body>
</html>
.ﺪﯿﻫﺩ ﺭﺍﺮﻗ ﺩﻮﺧ ﻩﺍﻮﺨﻟﺩ ﻪﺑ <body>
ﺎﯾ <head>
ﺭﺩ ﺍﺭ ﯽﺟﺭ
.ﺩﺭﺍﺩ ﺭﺍﺮﻗ <script>
ﮓﺗ ﻪﮐ ﺩﺭﺍﺩ ﺭﺍﺮﻗ ﯽﯾﺎﺟ ﺭﺩ ﺎًﻘﯿﻗﺩ ﯽﯾﻮﮔ ﻪﮐ ﺩﺮﮐ ﺪﻫﺍﻮﺧ ﺭﺎﺘﻓﺭ ﯼﺭﻮﻃ ﺖﭙﯾﺮﮑ
.ﺪﻨﺷﺎﺑ <script>
ﯼﺎﻫ ﺐﺴﭼﺮﺑ ﯼﻭﺎﺣ ﺪﻨﻧﺍﻮﺗ ﯽﻤﻧ ﯽﺟﺭﺎﺧ ﯼﺎﻫ ﺖﭙﯾﺮﮑﺳﺍ
:ﺩﺭﺍﺩ ﯽﯾﺎﯾﺍﺰﻣ ﯽﺟﺭﺎﺧ ﯼﺎﻫ ﻞﯾﺎﻓ ﺭﺩ ﺎﻫ ﺖﭙﯾﺮﮑﺳﺍ ﻥﺩﺍﺩ ﺭﺍﺮﻗ
HTML ﺪﻨﮐ ﯽﻣ ﺍﺪﺟ ﻢﻫ ﺯﺍ ﺍﺭ ﺪﮐ ﻭ
ﺪﻨﮐﯽﻣ ﺮﺗﻥﺎﺳﺁ ﺍﺭ JavaScript ﻭ HTML ﯼﺭﺍﺪﻬﮕﻧ ﻭ ﻥﺪﻧﺍﻮﺧ
ﺪﻨﻫﺩ ﺶﯾﺍﺰﻓﺍ ﺍﺭ ﻪﺤﻔﺻ ﯼﺭﺍﺬﮔﺭﺎﺑ ﺖﻋﺮﺳ ﺪﻨﻧﺍﻮﺗ ﯽﻣ ﻩﺪﺷ ﻩﺮﯿﺧﺫ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﯼﺎﻫ ﻞﯾﺎﻓ
:ﺪﯿﻨﮐ ﻩﺩﺎﻔﺘﺳﺍ ﺖﭙﯾﺮﮑﺳﺍ ﮓﺗ ﻦﯾﺪﻨﭼ ﺯﺍ - ﻪﺤﻔﺻ ﮏﯾ ﻪﺑ ﺖﭙﯾﺮﮑﺳﺍ ﻞﯾﺎﻓ ﻦﯾﺪﻨﭼ ﻥﺩﻭﺰﻓﺍ ﯼﺍﺮﺑ
<script src="myScript1.js"></script>
<script src="myScript2.js"></script>
:ﺩﺍﺩ ﻉﺎﺟﺭﺍ ﻒﻠﺘﺨﻣ ﺵﻭﺭ 3 ﻪﺑ ﻥﺍﻮﺗ ﯽﻣ ﺍﺭ ﯽﺟﺭﺎﺧ ﺖﭙﯾﺮﮑﺳﺍ ﮏﯾ
(ﻞﻣﺎﮐ ﺏﻭ ﺱﺭﺩﺁ ﮏﯾ) ﻞﻣﺎﮐ URL ﮏﯾ ﺎﺑ
(/js/ ﺪﻨﻧﺎﻣ) ﻞﯾﺎﻓ ﺮﯿﺴﻣ ﮏﯾ ﺎﺑ
ﯼﺮﯿﺴﻣ ﭻﯿﻫ ﻥﻭﺪﺑ
:ﺪﻨﮐ ﯽﻣ ﻩﺩﺎﻔﺘﺳﺍ myScript.js ﻪﺑ ﺪﻧﻮﯿﭘ ﯼﺍﺮﺑ ﻞﻣﺎﮐ b>URL> ﮏﯾ ﺯﺍ ﻝﺎﺜﻣ ﻦﯾﺍ
<script src="https://www.w3schools.com/js/myScript.js"></script>
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h2>External JavaScript</h2>
<p id="demo">A Paragraph.</p>
<button type="button" onclick="myFunction()">Click Me</button>
<p>This example uses a full web URL to link to "myScript.js".</p>
<p>(myFunction is stored in "myScript.js")</p>
<script src="https://www.w3schools.com/js/myScript.js"></script>
</body>
</html>
:ﺪﻨﮐ ﯽﻣ ﻩﺩﺎﻔﺘﺳﺍ myScript.js ﻪﺑ ﺪﻧﻮﯿﭘ ﯼﺍﺮﺑ ﻞﯾﺎﻓ ﺮﯿﺴﻣ ﮏﯾ ﺯﺍ ﻝﺎﺜﻣ ﻦﯾﺍ
<script src="/js/myScript.js"></script>
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h2>External JavaScript</h2>
<p id="demo">A Paragraph.</p>
<button type="button" onclick="myFunction()">Try it</button>
<p>This example uses a file path to link to "myScript.js".</p>
<p>(myFunction is stored in "myScript.js")</p>
<script src="/js/myScript.js"></script>
</body>
</html>
:ﺪﻨﮐ ﯽﻤﻧ ﻩﺩﺎﻔﺘﺳﺍ myScript.js ﻪﺑ ﺪﻧﻮﯿﭘ ﯼﺍﺮﺑ ﯼﺮﯿﺴﻣ ﭻﯿﻫ ﺯﺍ ﻝﺎﺜﻣ ﻦﯾﺍ
<script src="myScript.js"></script>
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h2>Demo External JavaScript</h2>
<p id="demo">A Paragraph.</p>
<button type="button" onclick="myFunction()">Try it</button>
<p>This example links to "myScript.js".</p>
<p>(myFunction is stored in "myScript.js")</p>
<script src="myScript.js"></script>
</body>
</html>
ﺪﯿﻧﺍﻮﺨﺑ HTML ﻞﺼﻓ ﺭﺩ ﻞﯾﺎﻓ ﯼﺎﻫﺮﯿﺴﻣ ﺩﺭﻮﻣ ﺭﺩ ﯼﺮﺘﺸﯿﺑ ﺕﺎﻋﻼﻃﺍ ﺪﯿﻧﺍﻮﺗ ﯽﻣ