Web-centric Computing

Some Example Code

JavaScript Dual Presentation

Part 2: How it is done

The essential parts of the markup are:

   <!-- ... -->
     This is the text that users
     <em>without</em> Javascript
     will see.
   <!-- ... -->

If the browser supports JS

If JS is understood by the browser then the <script type="text/javascript" ...></script> is run.

The file it loads contains document.writeln statements. Those statements create virtual markup that the browser writes into a buffer and then reads as though they had appeared in place of the <script> ... </script>.

[view the Javascript file]


But if JS is not understood by the browser then the browser presents the markup in the noscript container instead.


  1. Why will this technique work even with browsers that were written before Javascript was invented (for example, Netscape version 1)?
    1. What is the name we use for that concept?
    2. What is another example of that concept in HTML?
  2. Why is the type="text/javascript" in the script necessary?
  3. Why do you think the script element has an open and close tag (but never any contents)?

But what about the pop-up dialogue box?

Where did that annoying dialogue box come from?

25 April 2002
J. Blustein <jamie@cs.dal.ca>