Js Bom Events 120401044137 Phpapp02 PDF
Js Bom Events 120401044137 Phpapp02 PDF
Js Bom Events 120401044137 Phpapp02 PDF
window.setInterval('alert("I will
reappear every 3 seconds.")', 3000);
window.screen
• DocumentaDon
– https://developer.mozilla.org/en-US/docs/Web/
API/window.screen
window.navigator
• navigator
tells
informaDon
about
your
browser
• DocumentaDon
– hYps://developer.mozilla.org/en-‐US/docs/Web/API/
Navigator
• Client-‐sniffing
var browser = navigator.appName;
var b_version = navigator.appVersion;
var version = parseFloat(b_version);
BMI<br/>
<input type="text" name="result"/>
</form>
<script type="text/javascript">
//<![CDATA[
function count()
{
// Uses DOM LEVEL 0
var height = document.myform.height.value;
var weight = document.myform.weight.value;
document.myform.result.value = (weight / (height*height));
return false;
}
//]]>
</script>
Advanced
Event
Handling
• W3C
and
Microsoc
have
their
own
event
registraDon
model
– Since
IE9
MS
decided
to
support
also
W3C
model!
• W3C
model
is
supported
in
WebKit/Blink
(chrome
+
safari
+
opera),
firefox
(gecko)
and
IE9
-‐>
• In
W3C
event
model,
it's
possible
to
register
as
many
event
handlers
as
you
like
for
the
same
event
on
one
element.
<a href="http://www.tamk.fi" id="mylink">Click Me!</a>
<script>
function showAlert1()
{
alert("click 1!");
}
function showAlert2()
{
alert("click 2!");
}
</script>
true
or
false?
• The
boolean
value
(true,
false)
is
related
to
event
handling
order
• If
an
element
and
one
of
its
ancestors
have
an
event
handler
for
the
same
event,
which
one
should
fire
first?
• See
– hYp://www.quirksmode.org/js/events_order.html
• See
also
good
summary:
– hYp://www.w3.org/wiki/
Handling_events_with_JavaScript