\nslide4. DOM Event Handlers HTML element event handlers fine for elements, not good for the entire webpage if it means adding handlers to every single element\nVarious DOM Event Handlers\nComplicated by different methods for different browsers and different versions
\n\n\n

\nslide5. Evolution – Make a event utility In file eventutility.js:\n\nvar eventUtility = {\n\taddEvent : (function() {\n\t\tif (typeof addEventListener === \"function\") {\n\t\t\treturn function(obj, evt, fn) {\n\t\t\t\tobj.addEventListener(evt, fn, false);\n\t\t\t};\n\t\t} else {\n\t\t\treturn function(obj, evt, fn) {\n\t\t\t\tobj.attachEvent(\"on\" + evt, fn);\n\t\t\t};\n\t\t}\n\t}()),\n\tremoveEvent : (function() {\n\t\tif (typeof addEventListener === \"function\") {\n\t\t\treturn function(obj, evt, fn) {\n\t\t\t\tobj.removeEventListener(evt, fn, false);\n\t\t\t};\n\t\t} else {\n\t\t\treturn function(obj, evt, fn) {\n\t\t\t\tobj.detachEvent(\"on\" + evt, fn);\n\t\t\t};\n\t\t}\n\t}())\n};
\nslide6. HTML / JavaScript Code
\n\n\n
\n\n\n
\nslide7. Accessing the Event Target Use event.type and event.target to determine the event and target of the event
\n\n\n
\n\n\n
\nslide8. Event Target Can use the same event handler for multiple targets
\n\n
\n\n
\n\n\n\n
\nslide9. AJAX Term invented by Jesse Garrett, 2005, “Ajax: A New Approach to Web Applications”\nAsynchronous JavaScript + XML\nAlthough XML still used, other formats also used as well\nIn general, the use of JavaScript to send and receive data using HTTP without reloading the page\nAllows for dynamic pages without clunky submit/reload paradigm
\nslide10. AJAX and the XHR Object XHR = XMLHttpRequest Object\nOriginated as a component, XmlHttp, in Microsoft’s MSXML Library\nStill necessary if you’re programming for old versions of IE\nBuilt into modern browsers\nDespite the XML name you can retrieve more than XML and is commonly used with plaintext\nMust be used with a HTTP server\nCreating an XHR obje" }

Intro to JavaScript Events JavaScript Events

Intro to JavaScript Events JavaScript Events
1 / 1
Intro to JavaScript Events JavaScript Events - slide 1 of 18 Intro to JavaScript Events JavaScript Events - slide 2 of 18 Intro to JavaScript Events JavaScript Events - slide 3 of 18 Intro to JavaScript Events JavaScript Events - slide 4 of 18 Intro to JavaScript Events JavaScript Events - slide 5 of 18 Intro to JavaScript Events JavaScript Events - slide 6 of 18 Intro to JavaScript Events JavaScript Events - slide 7 of 18 Intro to JavaScript Events JavaScript Events - slide 8 of 18 Intro to JavaScript Events JavaScript Events - slide 9 of 18 Intro to JavaScript Events JavaScript Events - slide 10 of 18 Intro to JavaScript Events JavaScript Events - slide 11 of 18 Intro to JavaScript Events JavaScript Events - slide 12 of 18 Intro to JavaScript Events JavaScript Events - slide 13 of 18 Intro to JavaScript Events JavaScript Events - slide 14 of 18 Intro to JavaScript Events JavaScript Events - slide 15 of 18 Intro to JavaScript Events JavaScript Events - slide 16 of 18 Intro to JavaScript Events JavaScript Events - slide 17 of 18 Intro to JavaScript Events JavaScript Events - slide 18 of 18
Intro to JavaScript Events JavaScript Events Events in JavaScript let a web page react to some type of input Many different ways to handle events due to historyvendor differences but we have a generally standard way now Will not cover all

Related Topics

Download this presentation From Below

"Intro to JavaScript Events JavaScript Events" is the property of its rightful owner. Permission is granted to download and print the materials on this website for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.

Presentation Transcript

01
Intro to JavaScript Events<br>
02
JavaScript Events Events in JavaScript let a web page react to some type of input
Many different ways to handle events due to history/vendor differences but we have a generally standard way now
Will not cover all event levels
Events
W3C DOM Standard; attach to HTML elements
DOM Levels 0 to 3<br>
03
Event Handlers to HTML Attributes We can add an event handler to a HTML element
onkeydown, onkeyup, onkeypress
onclick, onmouseover, onmouseout, onmousedown, onmouseup
Others… <form name="theForm" action="">
<input type=text name="myTextBox" id="text1" value="1" onclick="addOne();">
</form>

<div id="myDiv" onmouseover="changeColor(this,'red');"
onmouseout="changeColor(this,'black');">
Hello there
</div> <script type="text/javascript">
function addOne()
{
var el = document.theForm.myTextBox;
el.value = parseInt(el.value) + 1;
}

function changeColor(el, col)
{
el.style.color = col;
}
</script><br>