ﻪﺑ ﺎﺠﮐ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ


فهرست مطالب

    نمایش فهرست مطالب


<script> ﮓﺗ

.ﺩﻮﺷﯽﻣ ﺝﺭﺩ </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

.ﺪﻨﮐﯽﻣ ﮏﯿﻠﮐ ﻪﻤﮐﺩ ﮏﯾ ﯼﻭﺭ ﺮﺑﺭﺎﮐ ﻪﮐ ﯽﻧﺎﻣﺯ ﺪﻨﻧﺎﻣ ،ﺩﺮﮐ ﯽﻧﺍﻮﺧﺍﺮﻓ ﺍﺭ ﻊﺑﺎﺗ ﮏﯾ ﻥﺍﻮﺗﯽﻣ ،ﺪﻫﺩﯽﻣ ﺥﺭ ﺩﺍﺪﯾﻭﺭ

.ﺖﺧﻮﻣﺁ ﺪﯿﻫﺍﻮﺧ ﺎﻫﺩﺍﺪﯾﻭﺭ ﻭ ﺎﻫﺩﺮﮑﻠﻤﻋ ﺩﺭﻮﻣ ﺭﺩ ﯼﺮﺘﺸﯿﺑ ﺕﺎﻋﻼﻃﺍ ﯼﺪﻌﺑ ﯼﺎﻫ ﻞﺼﻓ ﺭﺩ


<body> ﺎﯾ <head> ﺭﺩ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ

.ﺪﯿﻫﺩ ﺭﺍﺮﻗ HTML ﺪﻨﺳ ﮏﯾ ﺭﺩ ﺍﺭ ﺖﭙﯾﺮﮑﺳﺍ ﺩﺍﺪﻌﺗ ﺮﻫ ﺪﯿﻧﺍﻮﺗ ﯽﻣ ﺎﻤﺷ

ﻭﺩ ﺮﻫ ﺭﺩ ﺎﯾ ،ﺩﺍﺩ ﺭﺍﺮﻗ HTML ﻪﺤﻔﺻ ﮏﯾ <head> ﺶﺨﺑ ﺭﺩ ﺎﯾ <body>


<head> ﺭﺩ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ

.ﺖﺳﺍ ﻩﺪﺷ ﻩﺩﺍﺩ ﺭﺍﺮﻗ <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> 


<body> ﺭﺩ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ

.ﺖﺳﺍ ﻩﺪﺷ ﻩﺩﺍﺩ ﺭﺍﺮﻗ 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> ﺮﺼﻨﻋ ﻦﯿﯾﺎﭘ ﺭﺩ ﺎﻫ ﺖﭙﯾﺮﮑﺳﺍ ﻥﺩﺍﺩ ﺭﺍﺮﻗ


ﯽﺟﺭﺎﺧ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ

:ﺩﺍﺩ ﺭﺍﺮﻗ ﺰﯿﻧ ﯽﺟﺭﺎﺧ ﯼﺎﻫ ﻞﯾﺎﻓ ﺭﺩ ﻥﺍﻮﺗ ﯽﻣ ﺍﺭ ﺎﻫ ﺖﭙﯾﺮﮑﺳﺍ

myScript.js :ﯽﺟﺭﺎﺧ ﻞﯾﺎﻓ

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 ﻞﺼﻓ ﺭﺩ ﻞﯾﺎﻓ ﯼﺎﻫﺮﯿﺴﻣ ﺩﺭﻮﻣ ﺭﺩ ﯼﺮﺘﺸﯿﺑ ﺕﺎﻋﻼﻃﺍ ﺪﯿﻧﺍﻮﺗ ﯽﻣ

تمامی حقوق محفوظ است. © BasicIT.org • 2023-2024