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


Groups > comp.lang.javascript > #18909

Re: JavaScript Newbie

From JJ <jaejunks@nah.meh>
Newsgroups comp.lang.javascript
Subject Re: JavaScript Newbie
Date 2013-03-15 20:48 +0000
Organization A noiseless patient Spider
Message-ID <XnsA18527CF5E7DEjj@0.0.0.18> (permalink)
References <eee039e6-69a2-413d-bc99-f339dc1410e4@googlegroups.com>

Show all headers | View raw


Rich Rohde <rich@richware.net> wrote:
> I'm having somewhat of a problem.
> 
> Objective: include common html code in several html pages. should be
> simple. 

Maybe it's simple, but there are usualy consequences for doing things the 
easy way.

> Created: subroutines.js with
> 
> 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
> }

That should be "document", not "Document".
That "Result" would cause an error too.
Whatever comments or non-code lines in your code, should be made as 
comments to make things more clear.

> In my HTML I have:
> 
> <head>
> .
> .
>   <script type="text/javascript" src="/js/subroutines.js"></script>
> </head>
> 
> <body>
> .
> .
> .
>   createNavigation();
> .
> .
> 
> </body
> 
> Nothing shows, any help would be appreciated. 

Generally, that "createNavigation();" should work *assuming* that it's 
placed inside a SCRIPT element. However, it may be executed before the JS 
file is loaded and executed.

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