jasongr
09-15-2005, 07:03 AM
Hello,
My application uses Web pages whose grid is defined by several tables. I noticed a funny behavior on IE and Firefox which is giving me pains.
Apparently, when the browser renders a <table> tag and before it reaches the </table> end tag, any document.write actions in Javascript get deferred execution till closure of table instead of occuring at runtime as they are parsed.
The following snippet demonstrates the problem:
<html> <body>
<script language="javascript">
document.write("before table");
alert("before table");
</script>
<table>
<script language="javascript">
document.write("in table PROBLEM");
alert("in table");
</script>
</table>
<script language="javascript">
document.write("after table");
alert("after table");
</script>
</body> </html>
When this snippet is run, the problematic document.write of "in table" gets deferred till after the table gets closed.
We use alert() calls here to stop rendering and clarify what happens when. You can see that the other document.write calls that are not in mid-table, are displayed properly.
In our real-world app this gives us a problem wherein we use document.write to render code that displays a Flash navigation menu component, but this Flash menu appears after the table tag is closed which is after rendering of entire page, so the Flash shows up to users very late after most of the page has loaded instead of showing up early as we require it.
Since we have to use the table as part of the layout grid of the site, please advise how to work around this issue.
Note that we render the Flash using document.write because we have a Javascript check if Flash exists or not, and if not, we render an alternative non-Flash menu.
Thanks!
My application uses Web pages whose grid is defined by several tables. I noticed a funny behavior on IE and Firefox which is giving me pains.
Apparently, when the browser renders a <table> tag and before it reaches the </table> end tag, any document.write actions in Javascript get deferred execution till closure of table instead of occuring at runtime as they are parsed.
The following snippet demonstrates the problem:
<html> <body>
<script language="javascript">
document.write("before table");
alert("before table");
</script>
<table>
<script language="javascript">
document.write("in table PROBLEM");
alert("in table");
</script>
</table>
<script language="javascript">
document.write("after table");
alert("after table");
</script>
</body> </html>
When this snippet is run, the problematic document.write of "in table" gets deferred till after the table gets closed.
We use alert() calls here to stop rendering and clarify what happens when. You can see that the other document.write calls that are not in mid-table, are displayed properly.
In our real-world app this gives us a problem wherein we use document.write to render code that displays a Flash navigation menu component, but this Flash menu appears after the table tag is closed which is after rendering of entire page, so the Flash shows up to users very late after most of the page has loaded instead of showing up early as we require it.
Since we have to use the table as part of the layout grid of the site, please advise how to work around this issue.
Note that we render the Flash using document.write because we have a Javascript check if Flash exists or not, and if not, we render an alternative non-Flash menu.
Thanks!