nntp said:
By the way, onmouseover, onblur are all ok. But they require the mouse to
move to the object. Is there a way to make the script run 100%? BODY tag is
not allowed either, so I have to either use a huge table for onmouseover. Is
there any event like onmousemove?
I think it best you explain what you are trying to achieve. How can
you have a table if you don't have a body? You can execute scripts by
just putting commands inside <script> tags, a trivial example is below.
Note that the script executes when the browser reaches it, not when it
has actually rendered the page. Onload was created to run *after* the
page is fully loaded. In the example, the alert in the header runs
before the <body> tag is reached (or the </head> tag for that matter).
The alert in the body will likely run before the page is rendered too,
certainly before images have finished loading, and finally, after the
page is loaded and rendered, the onload will run.
Since you don't want to have a body tag, I presume you are writing the
entire page using JavaScript, which seems quite pointless to me, but if
that's what you want to do have a search for the thread on "writing
slabs of HTML", it should be useful. There is a second example below.
Cheers, Fred.
*Example I:*
<html><head><title> Auto Run </title>
<script type="text/javascript">
doStuff();
function doStuff() {
alert('doStuff\(\) says hello');
}
</script>
</head>
<body onload="alert('Hi from onload');"
style="background-color: #eeeeff;">
<h2>Here is the body</h2>
<script type="text/javascript">
alert('Here I am in the body');
</script>
</body>
</html>
*Example II:*
<html><head><title> Auto Run </title>
</head>
<script type="text/javascript">
var a = [
'<body><h2>here is some text<\/h2>',
'<form action="">',
'<input type="button" value="Click me" ',
'onclick="alert(\'Hi guys\');">',
'<\/form>',
'<\/body>',
];
document.write(a.join(""));
document.close();
</script>
</html>