ADDING FUNCTIONS TO WEBSITE

Similar documents
Introduction to JavaScript p. 1 JavaScript Myths p. 2 Versions of JavaScript p. 2 Client-Side JavaScript p. 3 JavaScript in Other Contexts p.

JavaScript & DHTML Cookbool(

Web Programming and Design. MPT Junior Cycle Tutor: Tamara Demonstrators: Aaron, Marion, Hugh

AIM. 10 September

This course is designed for web developers that want to learn HTML5, CSS3, JavaScript and jquery.

Web Site Development with HTML/JavaScrip

Introduction to Cascading Style Sheet (CSS)

A network is a group of two or more computers that are connected to share resources and information.

Lesson 5 Introduction to Cascading Style Sheets

Cascading style sheets, HTML, DOM and Javascript

Creating Web Pages with HTML-Level III Tutorials HTML 6.01

EXERCISE: Introduction to client side JavaScript

Session 3.1 Objectives Review the history and concepts of CSS Explore inline styles, embedded styles, and external style sheets Understand style

Cascading Style Sheets (CSS)

Web Programming and Design. MPT Senior Cycle Tutor: Tamara Week 2

Web standards and IE8

ADDING CSS TO YOUR HTML DOCUMENT. A FEW CSS VALUES (colour, size and the box model)

Best Practices Chapter 5

CSI 3140 WWW Structures, Techniques and Standards. Browsers and the DOM

Changing The User Agent String In Safari User Guide For Web Developers

JavaScript By: A. Mousavi & P. Broomhead SERG, School of Engineering Design, Brunel University, UK

HTML 5 and CSS 3, Illustrated Complete. Unit L: Programming Web Pages with JavaScript


Web Design and Development ACS-1809

Using Dreamweaver. 6 Styles in Websites. 1. Linked or Imported Stylesheets. 2. Embedded Styles. 3. Inline Styles

Programming the World Wide Web by Robert W. Sebesta

HTML, XHTML, and CSS. Sixth Edition. Chapter 1. Introduction to HTML, XHTML, and

Styles, Style Sheets, the Box Model and Liquid Layout

Browser Bugs & Validation

CUSTOMER PORTAL. Custom HTML splashpage Guide

Javascript. Many examples from Kyle Simpson: Scope and Closures

Frontend guide. Everything you need to know about HTML, CSS, JavaScript and DOM. Dejan V Čančarević

HTML5 MOCK TEST HTML5 MOCK TEST I

ADOBE 9A Adobe Dreamweaver CS4 ACE.

Using AJAX to Easily Integrate Rich Media Elements

Index. alt, 38, 57 class, 86, 88, 101, 107 href, 24, 51, 57 id, 86 88, 98 overview, 37. src, 37, 57. backend, WordPress, 146, 148

Web Design. Basic Concepts

Time: 3 hours. Full Marks: 70. The figures in the margin indicate full marks. Answer from all the Groups as directed. Group A.

To place an element at a specific position on a page use:

World Wide Web PROGRAMMING THE PEARSON EIGHTH EDITION. University of Colorado at Colorado Springs

JavaScript Programming

Govt. of Karnataka, Department of Technical Education Diploma in Computer Science & Engineering. Fifth Semester. Subject: Web Programming

Before you begin, make sure you have the images for these exercises saved in the location where you intend to create the Nuklear Family Website.

JavaScript and XHTML. Prof. D. Krupesha, PESIT, Bangalore

a Very Short Introduction to AngularJS

Mobile MOUSe WEB SITE DESIGN ONLINE COURSE OUTLINE

E ECMAScript, 21 elements collection, HTML, 30 31, 31. Index 161

CHAPTER 4 CASCADING STYLE SHEETS BASICS KEY CONCEPTS

USING STYLESHEETS TO DESIGN A WEB SITE IN DREAMWEAVER MX 2004

1. Setup a root folder for the website 2. Create a wireframe 3. Add content 4. Create hyperlinks between pages and to external websites

IT6503 WEB PROGRAMMING. Unit-I

COMS 359: Interactive Media

COMSC-031 Web Site Development- Part 2

Web Development. With PHP. Web Development With PHP

How to lay out a web page with CSS

Using Dreamweaver CC. Logo. 4 Creating a Template. Page Heading. Page content in this area. About Us Gallery Ordering Contact Us Links

Using Dreamweaver CS6

COMS 359: Interactive Media

COMS 359: Interactive Media

CSS: The Basics CISC 282 September 20, 2014

Overview of the Adobe Dreamweaver CS5 workspace

Introduction to using HTML to design webpages

Using Dreamweaver CC. 6 Styles in Websites. Exercise 1 Linked Styles vs Embedded Styles

Designing RIA Accessibility: A Yahoo UI (YUI) Menu Case Study

Cascading Style Sheets Level 2

1.1 Customize the Layout and Appearance of a Web Page. 1.2 Understand ASP.NET Intrinsic Objects. 1.3 Understand State Information in Web Applications

ITNP43: HTML Lecture 4

Web Development & Design Foundations with HTML5, 8 th Edition Instructor Materials Chapter 3 Test Bank

UNIT 3 SECTION 1 Answer the following questions Q.1: What is an editor? editor editor Q.2: What do you understand by a web browser?

Part of this connection identifies how the response can / should be provided to the client code via the use of a callback routine.

CS7026 CSS3. CSS3 Graphics Effects

How to lay out a web page with CSS

ORB Education Quality Teaching Resources

The Benefits of CSS. Less work: Change look of the whole site with one edit

[AVWSQ-ADWCS6]: WSQ ICDL Adobe Dreamweaver CS6

205CDE: Developing the Modern Web. Assignment 1: Designing a Website. Scenario: D Bookshop

The course also includes an overview of some of the most popular frameworks that you will most likely encounter in your real work environments.

State of the Browsers

Head First HTML 5 Programming: Chapter 3: Events, Handlers, and all that Jazz.

Corresponds to a layer in an HTML page and provides a means for manipulating that layer. Client-side object Implemented in JavaScript 1.

Independence Community College Independence, Kansas

Detect Users Browser Capabilities with PHP

SQA Advanced Unit specification. General information for centres. Unit title: Web Development Fundamentals. Unit code: HR7M 47

COMS 469: Interactive Media II

MIMS Online AD SPECIFICATIONS AND STYLE GUIDE 2018

XML: Introduction. !important Declaration... 9:11 #FIXED... 7:5 #IMPLIED... 7:5 #REQUIRED... Directive... 9:11

How to Control and Override CSS by Including a CSS Link

Basics of Web. First published on 3 July 2012 This is the 7 h Revised edition

Chapter 1: Getting Started. You will learn:

JavaScript CS 4640 Programming Languages for Web Applications

welcome to BOILERCAMP HOW TO WEB DEV

CSS Selectors. Web Authoring and Design. Benjamin Kenwright

Types of style sheets

Overview. Part I: Portraying the Internet as a collection of online information systems HTML/XHTML & CSS

Analysis of Hypertext Isolation Techniques for Cross-site Scripting Prevention. Mike Ter Louw Prithvi Bisht V.N. Venkatakrishnan

Using Dreamweaver CS6

Web Programming Pre-01A Web Programming Technologies. Aryo Pinandito, ST, M.MT

White Paper April Using Cascading Style Sheets (CSS) with AR System 6.x

BIM222 Internet Programming


Transcription:

ADDING FUNCTIONS TO WEBSITE

JavaScript Basics Dynamic HTML (DHTML) uses HTML, CSS and scripts (commonly Javascript) to provide interactive features on your web pages. The following sections will discuss the dynamic features of JavaScript in some detail, but before you can use these more advanced features it is important to ensure you understand the basics of the language such as: How to declare variables How to assign values to variables How to use constants How to declare and call functions How to write JavaScript expressions How to use operators and the maths functions How to use string functions How to use conditional and loop statements You will then be able to build on this basic knowledge to create dynamic web applications.

DHTML Basics Dynamic HTML (DHTML) uses HTML, CSS and scripts (commonly Javascript) to provide interactive features on your web pages. These features allow you to alter the content or position of HTML elements, based on user input or perhaps a timer. The main problem facing web developers who wish to use DHTML is browser compatibility. Using the W3C standards will reduce the compatibility problems but this won't solve all the problems. One technique used by developers is to test for the type of browser being used and provide alternative DHTML pages depending on the browser. To determine the browser type you can: Detect the browser using the navigator object Detect the browser at runtime

Detect the browser using the Navigator object The Document Object Model (DOM) does provide an aide to this dilemma, in the form of the Navigator object, a property of the Window object. Using the properties of the Navigator object, in theory at least, one can determine the client browser make, version, operating system, etc. Unfortunately the properties are not always implemented consistently, even by the same browser manufacturer. The standard approach of browser detection has been to convert the useragent or appname properties to lower or upper case and then perform a sub search for a known such as 'netscape' or 'msie'.

The Navigator Object The following table returns the properties from your current browser.

Attribute useragent: appname: appversion: appminorversio n: Result Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.107 Safari/535.1 Netscape 5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.107 Safari/535.1 undefined browserlangua ge: undefined systemlanguag e: undefined userlanguage: undefined cookieenabled: true platform: cpuclass: javaenabled: Win32 undefined true

Detect the browser at runtime Using features that are browser specific, makes it possible to detect the browser at runtime. For example only IE browsers recognise the element referencing scheme in the following code: document.allyou can use the fact this is IE specific code to determine what type of browser is being used to view the web page.

Once the browser type and functionality is known, a decision can be made at runtime, perhaps to redirect site content to subdirectories supporting the nominated browser. This requires extra work, time and consequently money! Some development houses may consider this to be a good PR exercise.

Colour Basics Colours can be specified in HTML pages by using a colour name or by using numbers. Perhaps the most common and versatile technique is to use a numeric value which consists of three two-digit hexadecimal numbers. Each pair describes the intensity of the corresponding colour. The first pair refers to red, the second pair to green and the third pair to blue. For example, the colour value #FF0000 is red because the red number is set to its highest value, FF (or 255 in decimal form). Note the use of the hash symbol '#'.

The Document Object Model The Document Object Model (DOM) is an interface that allows programmers to manipulate XML or HTML documents. Document Objects include the objects that can be described by HTML tags (such as tables and forms) as well as other objects for manipulating windows and performing other programming tasks. An object can be described by the properties, methods and events which can be applied to it.

A DHTML compatible browser views all the HTML elements (such as tags, forms, text etc.) as scriptable. The colour, position, visibility etc. of the HTML elements can be altered using a scripting language. In the browsers view of the HTML page, these elements are organised into a hierarchal structure, allowing the programmer to access these elements by navigating the hierarchy.

As explained previously one of the difficulties with the Document Object Model is programming for browser compatibility. The W3C specification for the Document Object Model is unfortunately different from the Microsoft IE 4 DOM. The W3C specification for the DOM is the standard to follow to achieve maximum browser compatibility. Unfortunately it won't guarantee it, especially with fourth generation browsers such as Netscape 4 and Microsoft IE 4. This discussion focusses on the W3C DOM and the IE proprietary model (referred to in this resource as the IE DOM). All examples indicate the model used. There may be some examples that you are unable to view, with your browser. You should try each example and take note of the browser compatibility issues.

Event Handlers Event handlers provide a mechanism to generate dynamic events in web pages. For example: Change text when a user clicks a mouse button Change one image with another when the mouse cursor moves over an image Display a menu when a document is loaded

Event Binding To execute some action (eg change the background colour of a button) as a result of some event (eg a mouse click) it is necessary to associate or bind an event handler to a page element (eg a button). There are a number of ways to go about this. You can: Embed the event handler within the element Assign an event handler to an object's event handling property Bind an event handler to the object via the script tag

Text ranges provide a mechanism for manipulating text on a page. You specify what text you want to manipulate (the text range). There are many differences between the IE and W3C DOM. In this section the discussion is confined to the IE DOM implementation. The examples are based on code from http://msdn.microsoft.com. To select the text in the entire body of the page, use the following code: somevariable = document.body.createtextrange () Once you have selected the text range you can manipulate it in some way, for example, delete or modify it. To refer to the actual text in the body of the document, type: somevariable.text

Dynamic Positioning Dynamic positioning of page elements relies on the CSS positioning attributes. With dynamic positioning you can specify: Where on the page you want your elements to reside Make them visible or remove their visibility Move the elements based on user action or a time-based event

To create a positionable element you use the position attribute within a CSS style rule. For example, to make a div element positionable you could use the following code: <div id="pdiv" style="position:absolute; left:50px; top:50px"> The inline style is used to make it easier to understand the code, but you could of course use cascading style sheets or the style tag to define the style of the div. The value of the position attribute can be: absolute fixed relative static inherit

With absolute positioning the element is positioned in relation to the elements container. The top left hand corner of the elements container is the position 0,0. With relative positioning the element is positioned relative to where it would normally have resided.

Attribute top right bottom left visibility z-index clip Description the element's position from the top edge of its context the element's position from the right edge of its context the element's position from the bottom edge of its context the element's position from the left edge of its context states whether an element is visible or not the stacking order of the element the viewable area of an element (absolute position only) overflow how overflow content is handled (eg clipped, made scrollable)