0% found this document useful (0 votes)
2 views

Java.lab4

This document outlines a lab exercise for JavaScript at Hamdard University, focusing on the basic structure, functions, and syntax of JavaScript. It covers topics such as the <script> tag, manipulating HTML elements, JavaScript variables, functions, and objects, along with practical tasks for students to complete. The lab tasks include creating web pages that demonstrate variable manipulation, user input, and object creation.

Uploaded by

laibazaheer1111
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
2 views

Java.lab4

This document outlines a lab exercise for JavaScript at Hamdard University, focusing on the basic structure, functions, and syntax of JavaScript. It covers topics such as the <script> tag, manipulating HTML elements, JavaScript variables, functions, and objects, along with practical tasks for students to complete. The lab tasks include creating web pages that demonstrate variable manipulation, user input, and object creation.

Uploaded by

laibazaheer1111
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 17
FACULTY OF ENGINEERING SCIENCES AND TECHNOLOGY Hamdard University Lab #04 JavaScript Objectives: * To lear the basic structure of JavaScript. * To learn the functions of Javascript Theory: What is JavaScript? * JavaScript and Java are two different computer languages. * [tis an object-oriented computer programming language commonly used to create interactive effects within web browsers. * JavaScript, is a text based object oriented computer programming language meant to run as part of a web-based application and to create interactive effects within web browsers. ‘* One of the three pillars of web development—the other two being HTML and Css. The JavaScript in or You can place an unlimited number of scripts in an HTML document. Scripts can be in the or in the section of HTML, and/or in both. It is a common practice to put functions in the section, or at the bottom of the page. This way they are all in one place and do not interfere with page content. JavaScript in In this example, JavaScript writes into the HTML while the page loads FACULTY OF ENGINEERING St Hamdard ») ) od SCIENCES AND TECHNOLOGY University

JavaScript can write directly into the HTML output stream:

You can only use document.write in the HTML output. If you use it after the document has loaded (e.g. in a function), the whole document will be overwritten.

JavaScript can write directly into the HTML output stream: This is a heading This is @ paragraph You can only use document.write in the HTML output. If you use it after the document has loaded (e.g. in a function), the whole document will be overwritten. External JavaScripts Scripts can also be placed in external files. Extemal files often contain code to be used FACULTY OF ENGINEERING SCIENCES AND TECHNOLOGY Hamdard University by several different web pages.External JavaScript files have the file extension .js.To use an external script, point to the js file in the "src" attribute of the My First Web Page My First Paragraph. After click Oops! The document disappeared! JavaScript Code JavaScript code (or just JavaScript) is a sequence of JavaScript statements. * Each statement is executed by the browser in the sequence they are written © This example will manipulate two HTML elements: ff (\\ a) we FACULTY OF ENGINEERING SCIENCES AND TECHNOLOGY Hamdard University My Web Page Hello Dolly How are you?

My Web Page

‘demo>A Paragraph.

spit yDIV">A DIV.
JavaScript Functions Declared functions are not executed immediately. They are "saved for later use", and will be executed later, when they are invoked (called upon) The function can be called directly when an event occurs (like when a user clicks a button), and it can be called from "anywhere" by JavaScript code FACULTY OF ENGINEERING SCIENCES AND TECHNOLOGY Hamdard University shead>

You might also like