JavaScript.2 2012. Объект окна window.propertyName window.methodName([parameters]) self.propertyName self.methodName([parameters]) propertyName methodName([parameters])

Презентация:



Advertisements
Похожие презентации
Using Dreamweaver MX Slide 1 Window menu Manage Sites… Window menu Manage Sites… 2 2 Open Dreamweaver 1 1 Set up a website folder (1). Click New…
Advertisements

Overview of the Paysonnel CE. Overview Paysonnel CE Go to URL- 1 Click [Login to Paysonnel CE] 2 How to Log-in to Paysonnel CE 1 2.
S5-1 PAT328, Section 5, September 2004 Copyright 2004 MSC.Software Corporation SECTION 5 RESULTS TITLE EDITOR.
DRAFTING and DIMENSIONING 98. A properly dimensioned drawing of a part is very important to the manufacturing outcome. With CATIA, it can be a very simple.
1 Учебный курс Введение в JavaScript и CGI Лекция 3 Программирование форм и графики кандидат технических наук Павел Брониславович Храмцов
S4-1 PAT328, Section 4, September 2004 Copyright 2004 MSC.Software Corporation SECTION 4 FIELD IMPORT AND EXPORT.
DRAWING USING SURFACES 115. To start your SURFACES drawing, go to new drawing, choose PART. Once the Part screen appears, click on START, choose MECHANICAL.
11 BASIC DRESS-UP FEATURES. LESSON II : DRESS UP FEATURES 12.
Service «Integrum Companies» step by step
DRAFTING TECHNIQUES I 136. Here is a basic shape. From here, we will do some advanced drafting once we put this shape on a sheet as a drawing. Select.
Slide title 70 pt CAPITALS Slide subtitle minimum 30 pt Ericsson Learning Interface ELI User guide.
WS19-1 WORKSHOP 19 EFFECTIVE MASS NAS122, Workshop 19, August 2005 Copyright 2005 MSC.Software Corporation.
WORKSHOP 5 COORDINATE SYSTEMS. WS5-2 NAS120, Workshop 5, May 2006 Copyright 2005 MSC.Software Corporation.
Cisco Systems Switches - Catalyst 2960 | Enhanced Metafile.
Escalating TAC Service Request © 2004 Cisco Systems, Inc. All rights reserved. IPTT v TAC Service Request and Telephone Service Providers.
WS2-1 WORKSHOP 2 NORMAL MODES ANALYSIS OF A 2 DOF STRUCTURE NAS122, Workshop 2, August 2005 Copyright 2005 MSC.Software Corporation.
Taking out Money from a Cash Machine Authors: Aleksey Ermolaev, Daria Zaitseva, Maria Leontyeva, Anatoly Leshchev, Form 10 pupils Teacher: V. V. Sergoushina,
1 Учебный курс Введение в JavaScript и CGI Лекция 1 Введение в JavaScript кандидат технических наук Павел Брониславович Храмцов
WS16-1 WORKSHOP 16 MODAL FREQUENCY ANALYSIS OF A CAR CHASSIS NAS122, Workshop 16, August 2005 Copyright 2005 MSC.Software Corporation.
© 2006 Cisco Systems, Inc. All rights reserved.CIPT2 v Monitor and Manage IP Telephony Introducing Cisco Unified CallManager Serviceability.
Транксрипт:

JavaScript

Объект окна window.propertyName window.methodName([parameters]) self.propertyName self.methodName([parameters]) propertyName methodName([parameters])

Создание окна var subWindow = window.open(define.html,def,HEIGHT =200,WIDTH=300) subWindow.close()

Ссылка на объекты окна Window Opener and Closer var newWindow function makeNewWindow() { newWindow = window.open(,,HEIGHT=300,WIDTH=300) } function closeNewWindow() { if (newWindow) { newWindow.close() newWindow = null }

window.status property Netscape

window.alert() method alert(This is a JavaScript alert dialog.)

window.confirm() method if (confirm(Are you sure you want to start over?)) { location.href = index.html }

window.prompt() var answer = prompt(What is your name?,) if (answer) { alert(Hello, + answer + !) }

The Location Object location.href = newWindow.location.href =

The History Object Window.history.go(-2)

The Document Object [window.]document.propertyName [window.]document.methodName([parame ters])

document.forms[ ] property document.forms.length document.forms[0] document.formName

document.title document.write document.writeln

document.write() Writing to Same Doc function reWrite() { // assemble content for new window var newContent = A New Doc newContent += This document is brand new. newContent += Click the Back button to see original document. newContent += // write HTML to new window document document.write(newContent) document.close() // close layout stream }

document.write() c другим окном Writing to Subwindow var newWindow function makeNewWindow() { newWindow = window.open(,,status,height=200,width=300) } function subWrite() { // make new window if someone has closed it if (newWindow.closed) { makeNewWindow() } // bring subwindow to front newWindow.focus() // assemble content for new window var newContent = A New Doc newContent += This document is brand new. newContent += // write HTML to new window document newWindow.document.write(newContent) newWindow.document.close() // close layout stream }

document.write() c другим окном (2)

The Link Object document.links[n].propertyName...

Задание 1.Напишите сценарий, который приветствует посетителя в строке статуса. 2.Напишите сценарий, который приветствует посетителя в заголовке окна. 3.Создайте страницу, запрашивающую у пользователя его имя в диалоговом окне и приветствующую пользователя в заголовке первого уровня.

The FORM Object document.forms[0] document.formName

Обращение к формам document.forms[0].action document.formName.action document.forms[0].action =

form.elements[ ] property var form = window.document.forms[0] for (var i = 0; i < form.elements.length; i++) { if (form.elements[i].type == text) { form.elements[i].value = }

Обращение к элементам форм function upperMe() { var field = document.forms[0].converter var upperCaseVersion = field.value.toUpperCase() field.value = upperCaseVersion }

Checkbox Checkbox Inspector function inspectBox() { if (document.forms[0].checkThis.checked) { alert(The box is checked.) } else { alert(The box is not checked at the moment.) } Check here

Переключатели document.forms[0].groupName.length document.forms[0].groupName[0].checked

Radio button Extracting Highlighted Radio Button function fullName() { var form = document.forms[0] for (var i = 0; i < form.stooges.length; i++) { if (form.stooges[i].checked) { break } alert(You chose + form.stooges[i].value +.) }

Radio button (2) Select your favorite Stooge: Moe Larry Curly

The SELECT Object document.form[0].selectName.selectedInd ex document.forms[0].selectName.options[n]. text document.forms[0].selectName.options[n]. value

Использование выбора function inspect() { var list = document.forms[0].choices var chosenItemText = list.options[list.selectedIndex].text }

Навигация с помощью select Select Navigation function goThere() { var list = document.forms[0].urlList location = list.options[list.selectedIndex].value } Choose a place to go: Home Page Shop Our Store Shipping Policies Search the Web

Пример использования форм (1) Beatle Picker function processData(form) { for (var i = 0; i < form.Beatles.length; i++) { if (form.Beatles[i].checked) { break } var beatle = form.Beatles[i].value var song = form.song.value

Пример использования форм (2) var beatle = form.Beatles[i].value var song = form.song.value alert(Checking whether + song + features + beatle +...) } function verifySong(entry) { var song = entry.value alert(Checking whether + song + is a Beatles tune...) }

Пример использования форм (3) Choose your favorite Beatle: John Paul George Ringo Enter the name of your favorite Beatles song:

Проверка заполнения формы Validator function checkForm(form) { for (var i = 0; i < form.elements.length; i++) { if (form.elements[i].value == ) { alert(Fill out ALL fields.) return false } return true }

Проверка заполнения формы (2) Please enter all requested information: First Name: Last Name: Rank: Serial Number:

Упражнения 1.Создайте страницу, в которой есть объект SELECT, изменяющий цвет фона на странице и переключатель, изменяющий цвет шрифта 2.Создайте 2 чекбокса, изменяющих цвет текста на странице на красный (1 –й переключатель), желтый (2 переключатель) и оранжевый (оба).