First, create a web page with a submit button on it (remember from creating forms in html?):

Similar documents
More cool scripts: Slide Show: What the settimeout() function does:

Create a cool image gallery using CSS visibility and positioning property

Implementing a chat button on TECHNICAL PAPER

How the Internet Works

Loops/Confirm Tutorial:

Introduction to HTML5

GIMP WEB 2.0 MENUS. Before we begin this tutorial let s visually compare a standard navigation bar and a web 2.0 navigation bar.

Lab 4 CSS CISC1600, Spring 2012

HTML Summary. All of the following are containers. Structure. Italics Bold. Line Break. Horizontal Rule. Non-break (hard) space.

HTML Overview. With an emphasis on XHTML

MP3 (W7,8,&9): HTML Validation (Debugging) Instruction

Perfect Student Midterm Exam March 20, 2007 Student ID: 9999 Exam: 7434 CS-081/Vickery Page 1 of 5

CSS Tutorial Part 1: Introduction: A. Adding Style to a Web Page (3 options):

Exam Format: Multiple Choice, True/False, Short Answer (3 points each 75 points total) Write-the-page (25 points)

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

**Method 3** By attaching a style sheet to your web page, and then placing all your styles in that new style sheet.

What is XHTML? XHTML is the language used to create and organize a web page:

Microsoft Expression Web Quickstart Guide

CS134 Web Site Design & Development. Quiz1

Shane Gellerman 10/17/11 LIS488 Assignment 3

JS Lab 1: (Due Thurs, April 27)

.hedgehog { background-image: url(backyard.jpg); color: #ffff99; height: 6in; width: 12in; } .tube {

Web Development & Design Foundations with XHTML. Chapter 2 Key Concepts

Part 3: Images & form styling NOMZAMO S WEBSITE

CSCI 1100L: Topics in Computing Spring 2018 Web Page Project 50 points

Wanted! Introduction. Step 1: Styling your poster. Activity Checklist. In this project, you ll learn how to make your own poster.

c122jan2714.notebook January 27, 2014

Create a three column layout using CSS, divs and floating

Dreamweaver: Portfolio Site

introduction to XHTML

Google Sites Guide Nursing Student Portfolio

Vebra Search Integration Guide

The default style for an unordered (bulleted) list is the bullet, or dot. You can change the style to either a square or a circle as follows:

I Can t Believe It s Not

Making Your PowerPoint Presentations Accessible

How to Make a Poster Using PowerPoint

Inline Elements Karl Kasischke WCC INP 150 Winter

Dreamweaver CS3 Lab 2

Schenker AB. Interface documentation Map integration

GIMP WEB 2.0 MENUS. Web 2.0 Menus: Horizontal Navigation Bar

CIS 228 (Fall 2011) Exam 2, 11/3/11

CMT111-01/M1: HTML & Dreamweaver. Creating an HTML Document

Study Guide 2 - HTML and CSS - Chap. 6,8,10,11,12 Name - Alexia Bernardo

TRAINING GUIDE. Rebranding Lucity Web

Title: Dec 11 3:40 PM (1 of 11)

CSS.

Chapter 4. Introduction to XHTML: Part 1

Unit Notes. ICAWEB411A Produce basic client-side script for dynamic web pages Topic 1 Introduction to JavaScript

A designers guide to creating & editing templates in EzPz

Text and Lists Use Styles. What Are Styles?

Reading 2.2 Cascading Style Sheets

Fundamentals: Client/Server

In this project, you ll learn how to create your own webpage to tell a story, joke or poem. Think about the story you want to tell.

How to Create Accessible Word (2016) Documents

ICT IGCSE Practical Revision Presentation Web Authoring

Title and Modify Page Properties

Micronet International College

Arrays/Branching Statements Tutorial:

Introduction to WEB PROGRAMMING

Creating an Accessible Microsoft Word document

Wireframe :: tistory wireframe tistory.

Building Your Blog Audience. Elise Bauer & Vanessa Fox BlogHer Conference Chicago July 27, 2007

This Tutorial is for Word 2007 but 2003 instructions are included in [brackets] after of each step.

Design Project. i385f Special Topics in Information Architecture Instructor: Don Turnbull. Elias Tzoc

ICT IGCSE Practical Revision Presentation Web Authoring

Programming Lab 1 (JS Hwk 3) Due Thursday, April 28

Controlling Appearance the Old Way

In the early days of the Web, designers just had the original 91 HTML tags to work with.

Basics of Page Format

Dreamweaver CS5 Lab 2

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

Non-English Web Pages In Dreamweaver MX

Problem Description Earned Max 1 HTML/CSS Interpretation 30 2 HTML/CSS Programming 30 3 JavaScript Programming 40 X Extra Credit +1 TOTAL 100

How browsers talk to servers. What does this do?

Web Publishing Basics I

CSS Positioning Using Expression Web Style Tools

3 Categories and Attributes

Modify cmp.htm, contactme.htm and create scheduleme.htm

COMP519 Web Programming Lecture 8: Cascading Style Sheets: Part 4 Handouts

Practice Test 3. 2) The onload event handler is used, most often, in association with which tag? a) a b) p c) body d) form

Lab Introduction to Cascading Style Sheets

CS Multimedia and Communications REMEMBER TO BRING YOUR MEMORY STICK TO EVERY LAB!

ORIGINAL FAMOUS RAY S HELL BURGER

ENGL 323: Writing for New Media Repurposing Content for the Web Part Two

8/19/2018. Web Development & Design Foundations with HTML5. Learning Objectives (1 of 2) Learning Objectives (2 of 2)

Dreamweaver Basics Workshop

CSS worksheet. JMC 105 Drake University

Full file at DW Chapter 2: Developing a Web Page

Interactive Tourist Map

Final Examination CIS 228: The Internet Prof. St. John Lehman College City University of New York 18 December 2008

Brand Guidelines 2012

PIC 40A. Midterm 1 Review

CSS: The Basics CISC 282 September 20, 2014

This booklet is knowledge of. a web page. of a web page find what you. you want to. SiteSell offers. Introduction

Boise Cascade Pro-Install Brand Packaging User Guide. Boise Cascade Building Materials Distribution, L.L.C.

Using Dreamweaver CS6

HTML TIPS FOR DESIGNING.

Guidelines for doing the short exercises

Ministry of Higher Education and Scientific Research

Web-One Infographics

Transcription:

Changing Style So far we have only done a little with changing the style of a web page. JavaScript lets us do that as well. We can call a function that allows us to change the style of one or many elements on the web page. We can do that as we ve been doing it, but instead, let s use a form s submit button. First, create a web page with a submit button on it (remember from creating forms in html?): Next we create a function that changes the style of a particular element. For now, I am going to just change the background color of the entire body of the web page. So my function will look like this: document.body.style.backgroundcolor = "#FF0000" Put it all together, and you get: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html lang="en-us" xml:lang="en-us" xmlns="http://www.w3.org/1999/xhtml"> <head> <title>our first javascript!</title> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <script type = "text/javascript"> document.body.style.backgroundcolor = "#FF0000" </script> </head> </body> </html> Different Colors: Let s expand this. Let s create a bunch of buttons that allow us to change the background color to different colors. First, let s create some more buttons: <input type = "submit" id = "yellowbtn" value = "yellow" onclick = "ChangeStyle('yellow')"/> <input type = "submit" id = "greenbtn" value = "green" onclick = "ChangeStyle('green')" /> <input type = "submit" id = "cyanbtn" value = "cyan" onclick = "ChangeStyle('cyan')" /> <input type = "submit" id = "bluebtn" value = "blue" onclick = "ChangeStyle('blue')" /> <input type = "submit" id = "purplebtn" value = "purple" onclick = "ChangeStyle('purple')"/> 1

Then let s modify the ChangeStyle() function so that when it is called with a particular variable, the body s background color changes to the appropriate color: document.body.style.backgroundcolor = "#FF3322" document.body.style.backgroundcolor = "#FCEF04" document.body.style.backgroundcolor = "#22DE43" document.body.style.backgroundcolor = "#10FAE4" document.body.style.backgroundcolor = "#4201D3" document.body.style.backgroundcolor = "#B900CD" Changing Style of other elements: We have changed the background color of the web page. We can change the style of other elements on the page as well. Of course, we ll need other elements on the page. First, create another element on the page. I m going to add a header: <input type = "submit" id = "yellowbtn" value = "yellow" onclick = "ChangeStyle('yellow')" /> <input type = "submit" id = "greenbtn" value = "green" onclick = "ChangeStyle('green')" /> <input type = "submit" id = "cyanbtn" value = "cyan" onclick = "ChangeStyle('cyan')" /> <input type = "submit" id = "bluebtn" value = "blue" onclick = "ChangeStyle('blue')" /> <input type = "submit" id = "purplebtn" value = "purple" onclick = "ChangeStyle('purple')" /> <h1 id = firstheader > Our Dynamic Style Page </h1> </body> Now, when a button is clicked, I m going to alter the background color of the firstheader element as well as the background color of the entire page: document.body.style.backgroundcolor = "#FF3322" document.getelementbyid('firstheader').style.backgroundcolor = "#57AF33" document.body.style.backgroundcolor = "#FCEF04" document.getelementbyid('firstheader').style.backgroundcolor = "#7788CC" 2

document.body.style.backgroundcolor = "#22DE43" document.getelementbyid('firstheader').style.backgroundcolor = "#0055FF" document.body.style.backgroundcolor = "#10FAE4" document.getelementbyid('firstheader').style.backgroundcolor = "#E410FA" document.body.style.backgroundcolor = "#4201D3" document.getelementbyid('firstheader').style.backgroundcolor = "#F3F300" document.body.style.backgroundcolor = "#B900CD" document.getelementbyid('firstheader').style.backgroundcolor = "#BBAADD" I m going to modify some other style properties of the firstheader element by adding: document.getelementbyid('firstheader').style.fontsize = "45px" document.getelementbyid('firstheader').style.fontfamily = "arial" document.getelementbyid('firstheader').style.padding = "20px" document.getelementbyid('firstheader').style.fontstyle = "italic" document.getelementbyid('firstheader').style.textalign = "right" document.getelementbyid('firstheader').style.borderstyle = "solid" document.getelementbyid('firstheader').style.borderwidth = "4px" My function will now look like: document.body.style.backgroundcolor = "#FF3322" document.getelementbyid('firstheader').style.backgroundcolor = "#57AF33" document.body.style.backgroundcolor = "#FCEF04" document.getelementbyid('firstheader').style.backgroundcolor = "#7788CC" document.body.style.backgroundcolor = "#22DE43" document.getelementbyid('firstheader').style.backgroundcolor = "#0055FF" document.body.style.backgroundcolor = "#10FAE4" document.getelementbyid('firstheader').style.backgroundcolor = "#E410FA" document.body.style.backgroundcolor = "#4201D3" document.getelementbyid('firstheader').style.backgroundcolor = "#F3F300" document.body.style.backgroundcolor = "#B900CD" document.getelementbyid('firstheader').style.backgroundcolor = "#BBAADD" document.getelementbyid('firstheader').style.fontsize = "45px" document.getelementbyid('firstheader').style.fontfamily = "arial" 3

document.getelementbyid('firstheader').style.padding = "20px" document.getelementbyid('firstheader').style.fontstyle = "italic" document.getelementbyid('firstheader').style.textalign = "right" document.getelementbyid('firstheader').style.borderstyle = "solid" document.getelementbyid('firstheader').style.borderwidth = "4px" Now that you know how to style using javascript, think about your average web page. How would you add a button that would adapt the page for those with red-green or blue-yellow color blindness? What about those with low vision who need a web page with high contrast? Try running a few web pages through http://colorfilter.wickline.org/ to see what they d look like to people with various forms of colorblindness. Optional Assignment (Extra: 10 pts): Take one of your web pages from your web site (or another web page you ve designed). Add a button that will change its style. Now create a function that either gives the page a holiday theme (holiday is of your choice) or adjusts the page for someone with low vision and color blindness difficulties (normally, you d have 2 separate buttons to accommodate people with low vision versus those with a particular type of color blindness. If you want 2 buttons, go for it. If you want just one button with both styles wrapped into one function, go for that. Design for Low Vision (From: http://www.alistapart.com/articles/lowvision/ ) Design basics Your low-vision design should do the following: Switch to a big font You can let the visitor enter a point size by keyboard, or you can give a reasonable set of predetermined options. Unless you re using something truly weird (Zapf Chancery, anyone?), you don t have to worry about font selection. Keep your line-height proportional. Invert the screen Many visitors will want light-on-dark text rather than the dark-on-light text we ve gotten used to since the first Macintosh. Customize colors However, bright white on flat black will not work for everyone; it s too bright. You can provide a few options, many of them reminiscent of 1980s-era terminals (e.g., green, yellow, or blue on black or dark brown, or the old WordPerfect 5.1 default of white on blue). Rearrange content This is the biggie: You have to judiciously prune your multicolumn site into one column. More Information: http://webdesign.about.com/od/accessibility/web_accessibility.htm http://otal.umd.edu/uupractice/vision/ 4

Extra: a javascript that cycles through potential background images, allowing the user to pick their background image: <script type = "text/javascript"> ls = new Array() ls[0] = "bg1.jpg" ls[1] = "bg7.jpg" ls[2] = "bg3.jpg" ls[3] = "bg4.jpg" count = -1 function loopforbackground(par1, par2) document.getelementbyid(par2).innerhtml = " " continuevar = true while (continuevar == true) count = count + 1 if (count >= ls.length) count = 0 document.images[par1].src = ls[count] continuevar = confirm("do you want to see another picture?") setstyle(par2) function setstyle(par2) document.body.style.backgroundimage = "url(\'" + ls[count] + "\')" document.getelementbyid(par2).innerhtml = "click here for other background options" document.getelementbyid(par2).style.color = "#FF0000" document.getelementbyid(par2).style.bordercolor = "#000000" document.getelementbyid(par2).style.borderwidth = "4px" document.getelementbyid(par2).style.borderstyle = "solid" document.getelementbyid(par2).style.backgroundcolor = "#FFFF00" document.getelementbyid(par2).style.width = "400px" document.getelementbyid(par2).style.padding = "5px" document.getelementbyid(par2).style.textalign = "center" </script> </head> <img width = "500" height = "374" alt = "area in which pics will be displayed" id = "display" /> <h3 id = "firsttext" onclick = "loopforbackground('display','firsttext')"> Click here to see potential pics... </h3>. 5