Why does the "onload" event attribute get stripped from the <body> tag in my kid template?

3 views
Skip to first unread message

loren...@gmail.com

unread,
Oct 26, 2005, 5:17:06 PM10/26/05
to TurboGears
Hi,

I'm exploring a lot of things which are new to me at once, and I'm not
sure where I've gone wrong...

I'm trying to set up a page that will periodically update a portion of
itself.
I tried this simple example but it doesn't work as a kid template. By
the time the document is rendered by the browser, the "onload" event
attribute is missing from my <body> tag.

Any ideas? Am I going about this all wrong?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns"http://www.w3.org/1999/xhtml"
xmlns:py="http://putl.org/kid/ns#"
py:extends+"'master.kid'">

<html>
<head>
<script type="text/javascript">
var c=0
var t
function timedCount()
{
document.getElementById('txt').value=c
c=c+1
t=setTimeout("timedCount()",1000)
}
</script>
</head>

<body onload="timedCount()>
<form>
<input type="text" id="txt">
</form>

<p>Automatically update the above text.</p>
</body>

</html>

Josu Oyanguren

unread,
Oct 26, 2005, 7:19:49 PM10/26/05
to turbo...@googlegroups.com
if you have a master.kid with

<body py:match="item.tag=='{http://www.w3.org/1999/xhtml}body'">
    [something ...]    
    <div py:replace="item[:]"/>
    ...

when the page is build, you get the contents of the body of your  template inserted. That is, you lose the onload attribute.

I have had this problem, and to workaround it, i modified master.kid so it says something like

<body onload="if (window.main) window.main()" py:match="item.tag=='{http...

so, if your page has a main function, it gets called and I put all the initialization work in than "main" function.

Josu.

2005/10/26, loren...@gmail.com <loren...@gmail.com>:

Janzert

unread,
Oct 26, 2005, 7:46:04 PM10/26/05
to turbo...@googlegroups.com
May or may not be the problem, but if that is a copy/paste of your template you are missing the closing quote for the onload attribute.

Janzert

Kevin Dangoor

unread,
Oct 26, 2005, 11:34:48 PM10/26/05
to turbo...@googlegroups.com
On 10/26/05, Josu Oyanguren <josu...@gmail.com> wrote:
> if you have a master.kid with
>
> <body
> py:match="item.tag=='{http://www.w3.org/1999/xhtml}body'">

Untested, but you might be able to do this:

<body py:match="item.tag=='{http://www.w3.org/1999/xhtml}body'"
py:attrs="item.items()">

Assuming that works, that would be a good thing to add to the default
master.kid.

Kevin
Reply all
Reply to author
Forward
0 new messages