473,473 Members | 1,425 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

window.onclick in IE and Gecko agents

Why window.onclick isn't fired in IE and is fired on Gecko agents ?

<html onclick="alert('Event is now at the HTML element.')">
<head>
<title>Event Bubbles</title>
<script type="text/javascript">
function init() {
document.onclick = docEvent;
window.onclick = winEvent

document.body.onclick = docBodEvent;
alert(document == window);
}
function winEvent() {
alert("Event is now at the window object level.");
}
function docEvent() {
alert("Event is now at the document object level.");
}
function docBodEvent() {
alert("Event is now at the BODY element.");
}
</script>
</head>
<body onload="init()">
<h1>Event Bubbles</h1>
<hr />
<form onclick="alert('Event is now at the FORM element.')">
<input type="button" value="Button 'main1'" name="main1"
onclick="alert('Event started at Button: ' + this.name)" />
</form>
</body>
</html>

Dec 2 '05 #1
6 2069
Ok i know the answer:
See the table below:
Event Bubbling Variations for Listing
Event Handler Location WinIE4+ MacIE4+ NN6+/Moz1+/Safari
button yes yes yes
form yes yes yes
body yes yes yes
HTML yes no yes
document yes yes yes
window no no yes

Dec 2 '05 #2
Luke Matuszewski wrote:
Ok i know the answer:
See the table below:
A reference to where the table came from would be helpful, or did you
make it yourself?

Event Bubbling Variations for Listing
Event Handler Location WinIE4+ MacIE4+ NN6+/Moz1+/Safari
button yes yes yes
form yes yes yes
body yes yes yes
HTML yes no yes
document yes yes yes
window no no yes

HTML 4.01 does not specify an onclick attribute for the HTML element,
the body element would be a more suitable location.

--
Rob
Dec 2 '05 #3

RobG napisal(a):
Luke Matuszewski wrote:
Ok i know the answer:
See the table below:
A reference to where the table came from would be helpful, or did you
make it yourself?

It comes from JavaScript Bible , 5th Ed by Danny Goodman (if i were
younger i would say :O :O :O .... ;-) ).

HTML 4.01 does not specify an onclick attribute for the HTML element,
the body element would be a more suitable location.


It refers not to <html> element (tag) but i guess the most of html
elements which has %events entity in DTD.

Dec 3 '05 #4
OF TOPIC

While searching in 1 ebook in Acrobat Reader 7 while writing this
post(switched from Acrobat to window where i was writting this post
when he stopped searching on first found result and i fired searching
again from page where the result was - 400) and then opening another
ebook and thus switched to Acrobat again a saw that it made no progress
because it continued from page 400 and even starded searching in new
opened ebook at page 1 !
I made few more switches to see it again - page 400 was always the
staring point in Acrobat for first ebook and page 1 for ebook 2 (no
progress in searching in 'background') - yep i think it is a bug :-)
try it your self (the bug is only when i open second ebook - which
triggers search in this ebook from 1 page :)

Dec 3 '05 #5
Luke Matuszewski wrote:
RobG napisal(a):

[...]
A reference to where the table came from would be helpful, or did you
make it yourself?


It comes from JavaScript Bible , 5th Ed by Danny Goodman (if i were
younger i would say :O :O :O .... ;-) ).


Goodman's book is not held in high regard, you might be better to not
use it at all. :-x

HTML 4.01 does not specify an onclick attribute for the HTML element,
the body element would be a more suitable location.


It refers not to <html> element (tag) but i guess the most of html
elements which has %events entity in DTD.


Not sure what you mean. Your original post had code with an onclick
attribute in an HTML tag, Goodman's table (as posted) seemed to suggest
that it was OK to added them. The HTML element has no events, so no
attempt should be made to to add them. If that is what Goodman's book
suggests or advises, then it's a good example of why you shouldn't use it.

Despite what the specification says, some browsers may support event
attributes being added to the HTML element. But that does not make it
OK to do so, as it can't be expected to be reliable across all browsers
conforming to HTML 4. There are a great many more browsers than those
in the table and mobile devices will likely grow the number hugely.
--
Rob
Dec 4 '05 #6

RobG napisal(a):
Luke Matuszewski wrote:
RobG napisal(a): [...]
A reference to where the table came from would be helpful, or did you
make it yourself?


It comes from JavaScript Bible , 5th Ed by Danny Goodman (if i were
younger i would say :O :O :O .... ;-) ).


Goodman's book is not held in high regard, you might be better to not
use it at all. :-x

HTML 4.01 does not specify an onclick attribute for the HTML element,
the body element would be a more suitable location.


It refers not to <html> element (tag) but i guess the most of html
elements which has %events entity in DTD.


Not sure what you mean. Your original post had code with an onclick
attribute in an HTML tag, Goodman's table (as posted) seemed to suggest
that it was OK to added them. The HTML element has no events, so no
attempt should be made to to add them. If that is what Goodman's book
suggests or advises, then it's a good example of why you shouldn't use it.

Ok as i read you reply i saw the onclick event in <html> element -
which is not good practice as HTML 4.01 spec states that <html> element
has no onclick event...

Thanks for answer, and sorry for example which is not valid HTML as
w3c.org states...

My experience on reading different books shows that in those books
there is only a suggestion on how things work and if they don't refer
to specifications it is ok - but that i have learned from experience.
Worst books refer to specification and provide material/examples that
are not valid when comparing what specification says.

Best way is to know specification or has quick access to them (as for
eg. to the Internet for checking w3c.org HTML specs) and then support
our knowledge by reading books.

Despite what the specification says, some browsers may support event
attributes being added to the HTML element. But that does not make it
OK to do so, as it can't be expected to be reliable across all browsers
conforming to HTML 4. There are a great many more browsers than those
in the table and mobile devices will likely grow the number hugely.


Yes, i agree and sorry for my (well Danny Goodman was first) example
provided from his book.

My way to learn things has evolved as i was misguided by many different
books... and i am in stage where i can say i do following:
- i learn/know the specification and how to search them;
- i read (now only fragments) of books which reveals some asspects of
knowledge and how this knowledge deals with real world (so eg. how it
works on different user agents), and while reading i especially try to
catch fragments which is not valid against specification;
- i try to remeber things that are specification valid and how they
work in real world today, cause only then i can say that maybe it will
work on the future and maybe they will work on not standards compilant
future devices - as producents of such devices will probably try to not
break compatibility which older versions (versions of devices which
work today);

BR.
Luke

Dec 4 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: Mike Gratee | last post by:
Is it possible to use JavaScript to cause the browser to click a link on a page and have the browser act exactly like the user had clicked on the link directly? In other words, I need to...
10
by: K. S. | last post by:
hi guys, this code works fine in IE but doesnot work in opera. the page just reloads to test.html# in opera. can anyone help? thanks. ...
2
by: Larry R Harrison Jr | last post by:
I have pull-down menus in javascript and I have the code for opening a link in a new window. But I want it to open a full-sized window. I can't figure out the syntax. What I have so far: ...
4
by: Andrew Poulos | last post by:
If I use this code to maximise a browser window: window.moveTo(0,0); window.resizeTo(screen.width,screen.height); it works but on Windows the user can have a taskbar visible and the browser...
1
by: tmp | last post by:
I want to have a 'help' popup on seveal key words on a page. I don't want to use a button... But would like to do it like a link... so the text on the page is the link to the Popup Window. ...
2
by: Craig Keightley | last post by:
I have a very simple confirm link on a website using the following code: function confirmNewSupplier(){ if(confirm(' Are you sure that you can\'t select a supplier from the list? ...
8
by: Luke Matuszewski | last post by:
I have read all posts about how to detect that url have changed to new page and trigger the event handler then eg. function aidLogout(evt) { if(evt) { /* maybe via analyse of evt object i can...
26
by: yb | last post by:
Hi, Is there a standard for the global 'window' object in browsers? For example, it supports methods such as setInterval and clearInterval, and several others. I know that w3c standardized...
21
by: David C | last post by:
I have an ASP.Net page that does a Response.Redirect to a code-created url. Is there any way to code the redirect to open a new window similar to the Javascript window.open() ? Thanks. David
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.