Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #23488
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: JavaScript in a PRE element of an HTML document |
| Date | 2014-03-09 22:16 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <lfip84$46g$1@dont-email.me> (permalink) |
| References | <JavaScript-20140308234930@ram.dialup.fu-berlin.de> <lfgsk3$hlv$1@dont-email.me> <teaching-frame-20140309152656@ram.dialup.fu-berlin.de> |
On Sun, 09 Mar 2014 14:31:15 +0000, Stefan Ram wrote:
> I plan to use
>
> <!DOCTYPE HTML><html><head><title>T</title><meta
> charset="UTF-8"></head><body><pre><code><script>
> ...
> </script></code></pre></body>
> as a general frame for such JavaScript teaching examples:
It might be a good idea to add a type attribute to your script element.
I see no closing tag for the html element.
I believe it is suggested that a charset line should appear as early as
possible, as it's presence may require that the document be reprocessed.
This usually means that, as I understand it, best practice is for it to
be the first element in the document head.
Have you considered using a textarea as the output region, rather than an
inline part of the document? Doing so would allow output from interactive
elements on the page at some future point, and would allow you to
separate the script code from the document structure.
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>T</title>
<script type="text/javascript">
function the_code() {
var o = document.getElementById("output");
var a = 5;
o.value = ""; // clear the output area
o.value += "1) a = " + a + "\n";
o.value += "2) a + 1 = " + ( a + 1 ) + "\n";
o.value += "3) a = " + a + "\n";
}
</script>
</head>
<body>
<p><input type="button" value="Run The Code" onclick="code();"></
p>
<h3>Output:</h3>
<textarea cols="80" rows="10" id="output" readonly="readonly"></
textarea>
</body>
</html>
--
Denis McMahon, denismfmcmahon@gmail.com
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: JavaScript in a PRE element of an HTML document "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2014-03-09 07:01 +0200
Re: JavaScript in a PRE element of an HTML document "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2014-03-09 17:05 +0200
Re: JavaScript in a PRE element of an HTML document Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-03-09 17:15 +0100
Re: JavaScript in a PRE element of an HTML document "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2014-03-09 19:25 +0200
Re: JavaScript in a PRE element of an HTML document "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-03-09 19:44 +0100
Re: JavaScript in a PRE element of an HTML document Dr J R Stockton <reply1400@merlyn.demon.co.uk.invalid> - 2014-03-10 18:01 +0000
Re: JavaScript in a PRE element of an HTML document "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-03-11 09:59 +0100
Re: JavaScript in a PRE element of an HTML document Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-03-09 16:54 +0100
Re: JavaScript in a PRE element of an HTML document Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-03-09 16:30 +0000
Re: JavaScript in a PRE element of an HTML document Denis McMahon <denismfmcmahon@gmail.com> - 2014-03-09 22:16 +0000
Re: JavaScript in a PRE element of an HTML document "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2014-03-10 07:30 +0200
csiph-web