anewt-developers team mailing list archive
-
anewt-developers team
-
Mailing list archive
-
Message #00151
[Bug 443180] Re: Not possible to add attributes to the body tag using AnewtPage
This is by design. Most of the times I've seen attributes on the body
tag, it was for one of those reasons:
1. Adding custom styling like colors or a 'style' attribute.
2. Adding a snippet of JavaScript to fire when the page has been loaded
For both, much better alternatives are available:
ad 1. Use stylesheets.
ad 2. Use proper JavaScript, inside the 'head' element or in an external file (which is even cleaner).
Re. the body.onload event: In 99.9% of the cases you actually don't
intend to do something after the page has been completely loaded (that
is when the load event fires). What you really want is to execute a
piece of JavaScript when the DOM tree is available for manipulation.
This is often quite some time *before* body.onload fires due to the
loading time of images and other external resources (e.g. stylesheets ).
Since browser implementations have different ways of telling JavaScript
that the DOM is ready, all JavaScript libraries have useful abstractions
for those events. For instance, with JQuery you can do this (html cut
down to the bare minimum; this is just a quick example):
<html>
<head>
<script src="jquery.js" />
<script>
$(document).ready(function() {
alert('The DOM is ready!');
});
</script>
</head>
<body>
<p>Hello, world!</p>
</body>
</html>
See http://www.learningjquery.com/2006/09/introducing-document-ready for
a more thorough explanation. This is also a useful page if you don't use
JQuery.
** Changed in: anewt
Status: New => Triaged
** Changed in: anewt
Assignee: (unassigned) => Wouter Bolsterlee (uws) (uws)
--
Not possible to add attributes to the body tag using AnewtPage
https://bugs.launchpad.net/bugs/443180
You received this bug notification because you are a member of Anewt
developers, which is subscribed to Anewt.
References