...

View Full Version : document.writeln(); TABLES CANT VIEW THEM



Ludwig2012
07-05-2012, 06:02 AM
Im trying to view my table through google chrome and i keep getting blank pages ?!?!

<html>
<head>
<title>Assignment1.2
<body>


<script language="JavaScript">

document.write("<table border='1'>");
document.write("<tr>");
document.write("<td>");
document.write("JavaScript Text which may or may not be output");
document.write("</td>");
document.write("<td>");
document.write("JavaScript Text which may or may not be output");
document.write("</td>");
document.write("</tr>");
document.write("</table>");

</script>


</body>
</html>

Philip M
07-05-2012, 07:21 AM
You have not closed your <title> tag.

Be aware that document.write() is in effect obsolete. document.write() statements must be run before the page finishes loading. Any document.write() statement that runs after the page finishes loading will create a new page and overwrite all of the content of the current page (including the Javascript which called it). So document.write() is at best really only useful to write the original content of your page. It cannot be used to update the content of your page after that page has loaded.

<script language=javascript> is long deprecated. Use <script type = "text/javascript"> instead (in fact also deprecated but still necessary for IE<9).


All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.

Ludwig2012
07-05-2012, 01:43 PM
Thank you ! I replaced all with document.writeln(), <script type = "text/javascript"> and closed my title all is good now :)

WolfShade
07-05-2012, 02:11 PM
<script language=javascript> is long deprecated. Use <script type = "text/javascript"> instead (in fact also deprecated but still necessary for IE<9).

Just out of curiosity, if even the type attribute is deprecated (except for IE<9), is it being replaced with anything? Or do we no longer have to indicate that the script is JavaScript (for future browsers)?

Philip M
07-05-2012, 03:19 PM
Thank you ! I replaced all with document.writeln(), <script type = "text/javascript"> and closed my title all is good now :)

Aaarrrggghhh! document.writeln() is as obsolete and useless as document.write(). The only difference is that document.writeln() adds a line feed/carriage return.

Philip M
07-05-2012, 03:27 PM
Just out of curiosity, if even the type attribute is deprecated (except for IE<9), is it being replaced with anything? Or do we no longer have to indicate that the script is JavaScript (for future browsers)?

The approved version is <script type = "application/javascript"> but there are still plenty of browsers around (especially IE<9) that don't recognise it. <script type = "text/javascript"> is fail-safe and works in all browsers. It is the default if just <script> is specified.

If you only care about HTML 5, just omit the type attribute entirely. It is optional and the default language is JavaScript. But HTML4 browsers will still be around for some years yet!

WolfShade
07-05-2012, 03:45 PM
I haven't started with HMTL5, yet. Last I heard, it still hasn't been standardized. I'll wait for that, before digging into it. And the fact that the HTML4 browsers (as you have stated) will be around for a while, yet.. (shrug)

But I'm glad to know that type="text/javascript" is fail-safe amongst all browsers.

Thanks,



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum