473,785 Members | 2,553 Online
Bytes | Software Development & Data Engineering Community
+ 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.onclic k = docEvent;
window.onclick = winEvent

document.body.o nclick = 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 2102
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
61445
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 programmatically issue a JavaScript statement which causes the browser to act just like the user clicked on a link in my page. And if that link has an onClick JS event defined, I'd want that onClick event to execute too, exactly the same as if the user...
10
5436
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. ----------------------------------------------------------------------- <html>
2
4412
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: Menu5_5_1=new Array("'Lonely Church","javascript:window.open ('http://www.photo.net/photodb/photo?photo_id=2640310')","",0,20,300); That works fine, except I can't figure out how to modify it to make it open full-screen.
4
6334
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 window goes behind it. Is there a way to know where the taskbar is?
1
2505
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. Can anyone provide me with a simple example of a JavaScript to do this. thanks in advance.
2
6415
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? \n(Click OK to request a new supplier or Cancel to return to the Directory)')){ window.location = 'l1stage1.php'; } }
8
17381
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 detect the close of the browser window */ } if(window.event) { /* maybe via analyse of window.event object i can detect the close of the browser window */
26
5694
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 several parts of the DOM, but this does not include the window object. Thank you
21
2405
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
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10090
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8971
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7499
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4050
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2879
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.