Friday, September 30, 2011

How to Attach External File of Javascript?

The process to attach a JavaScript file with the html file is -----


  1. First you have to create a JavaScript code file.
  2. Save it with extension .js.
  3. Now create an HTML code file.
  4. Give the complete address of js file into script tag under src=" ".
  5. Save it with extension .html or .htm.
  6. Run HTML file.
Example:--

JavaScript Code:---

var m1,m2,m3;
m1=prompt("Enter the 1st no.:");
m2=prompt("Enter the 2nd no.:");
m1=parseInt(m1);
m2=parseInt(m2);
m3=m1+m2;
document.write("Addition is :" +m3);

HTML Code:---


Input:---



Output:---
Addition is 36.

No comments:

Post a Comment

टी20 वर्ल्ड कप 2026: भारत ने रचा इतिहास, न्यूजीलैंड को 96 रनों से हराकर फिर बना विश्व विजेता! 🏆🇮🇳

अहमदाबाद, 9 मार्च 2026: नरेंद्र मोदी स्टेडियम में कल जो हुआ, उसे भारतीय क्रिकेट इतिहास में सुनहरे अक्षरों में लिखा जाएगा। 1.3 लाख से ज्यादा...