R
Roy Smith
I'm just learning js, and am confused by some behavior I'm seeing in
Chrome (version 5.0.375.127, OSX). This may be more of a browser issue
than a javascript issue, so my apologies if this is the wrong forum.
I've got the following little HTML file.
<html>
<head>
<script type="text/javascript">
function message()
{
document.write("<p>My message");
}
</script>
</head>
<body onload="message()">
</body>
</html>
when I load it into Chrome, I get a blank page. Loading this HTML:
<p>My message
displays "My message". A little experimenting shows that if I close the
<p> tag with </p> in the js version, "My message" gets displayed.
I don't understand why the browser cares about the closing tag when the
HTML comes from a script, and doesn't care when it's read from the file
directly.
Chrome (version 5.0.375.127, OSX). This may be more of a browser issue
than a javascript issue, so my apologies if this is the wrong forum.
I've got the following little HTML file.
<html>
<head>
<script type="text/javascript">
function message()
{
document.write("<p>My message");
}
</script>
</head>
<body onload="message()">
</body>
</html>
when I load it into Chrome, I get a blank page. Loading this HTML:
<p>My message
displays "My message". A little experimenting shows that if I close the
<p> tag with </p> in the js version, "My message" gets displayed.
I don't understand why the browser cares about the closing tag when the
HTML comes from a script, and doesn't care when it's read from the file
directly.