Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #18904

Re: JavaScript Newbie

From "Jukka K. Korpela" <jkorpela@cs.tut.fi>
Newsgroups comp.lang.javascript
Subject Re: JavaScript Newbie
Date 2013-03-15 08:04 +0200
Organization A noiseless patient Spider
Message-ID <khudhp$8bo$1@dont-email.me> (permalink)
References <eee039e6-69a2-413d-bc99-f339dc1410e4@googlegroups.com>

Show all headers | View raw


2013-03-14 23:05, Rich Rohde wrote:

> I'm having somewhat of a problem.

According to your Subject line, your problem is a JavaScript Newbie. 
Well, Newbies as such aren't much of a problem. At comp.lang.javascript, 
they are normally just ignored, and they at most confuse themselves if 
they happen to make the resident troll lecture pointlessly on things way 
above their heads, and his.

> Objective: include common html code in several html pages. should be simple.

Oh. So your problem might actually be "how do I include common html code 
in several pages?" Then you should perhaps have put *that* on the 
Subject line. Besides, you should have considered whether JavaScript is 
a useful tool then.

> function createNavigation() {
> var aHTML = '';
>      aHTML += '<div id=navigation>';
>      aHTML += '<ul>';
>      aHTML += '    <li><a href="/default.html">Home</a></li>';
> .
> .
>      aHTML += '</ul>';
>      aHTML += '</div>';
>      Document.write(aHTML);
>      Result
> }

It is sometimes very difficult to distinguish a wannabe novice's code 
from trolling. And...

> <body>
> .
> .
> .
>    createNavigation();
> .
> .
>
> </body

...putting a JavaScript function invocation right into HTML code makes 
this very hard.

But in case you are being serious, I'll just answer that it makes no 
sense to generate HTML navigation code with JavaScript on web pages. 
(After reading a good first primer on web technologies, should be able 
to easily list down half a dozen reasons to this.)

You should check out the tools available in the authoring environment. 
At the simplest, you would use Server-Side Includes (SSI).

In an application that uses web technologies, things are somewhat 
different, but you should not consider writing them yet. And you should 
not of course use document.write to add elements (still less try to use 
Document.write).

-- 
Yucca, http://www.cs.tut.fi/~jkorpela/

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

JavaScript Newbie Rich Rohde <rich@richware.net> - 2013-03-14 14:05 -0700
  Re: JavaScript Newbie "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2013-03-14 22:23 +0100
    Re: JavaScript Newbie Rich Rohde <rich@richware.net> - 2013-03-14 15:34 -0700
    Re: JavaScript Newbie Eric Bednarz <bednarz@fahr-zur-hoelle.org> - 2013-03-20 01:05 +0100
      Re: JavaScript Newbie "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2013-03-20 18:03 +0100
  Re: JavaScript Newbie "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2013-03-15 08:04 +0200
  Re: JavaScript Newbie JJ <jaejunks@nah.meh> - 2013-03-15 20:48 +0000
  Re: JavaScript Newbie Dr J R Stockton <reply1300@merlyn.demon.co.uk.invalid> - 2013-03-15 21:56 +0000

csiph-web