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


Groups > comp.lang.javascript > #18897 > unrolled thread

JavaScript Newbie

Started byRich Rohde <rich@richware.net>
First post2013-03-14 14:05 -0700
Last post2013-03-15 21:56 +0000
Articles 8 — 6 participants

Back to article view | Back to comp.lang.javascript


Contents

  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

#18897 — JavaScript Newbie

FromRich Rohde <rich@richware.net>
Date2013-03-14 14:05 -0700
SubjectJavaScript Newbie
Message-ID<eee039e6-69a2-413d-bc99-f339dc1410e4@googlegroups.com>
I'm having somewhat of a problem.

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

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
}


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. 
-Rich

[toc] | [next] | [standalone]


#18898

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2013-03-14 22:23 +0100
Message-ID<XnsA183E3B8A6CDFeejj99@194.109.133.133>
In reply to#18897
Rich Rohde wrote on 14 mrt 2013 in comp.lang.javascript:

> I'm having somewhat of a problem.
> 
> Objective: include common html code in several html pages. should be
> simple. 
> 
> Created: subroutines.js with


As a newbee, do not use js files,
but put your js-code in the HTML-file header part.

This eases debugging.

What is the sense of seperate files, 
except when you want them cached on the client, 
something you will not want when debugging.

Or when you are so sure of the code's perfection, 
that you use them in different html-pages.

> 
> 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

'Result' is not a js-command, you will get an error here.

Debugging would give this away.

>}
> 
> 
> In my HTML I have:
> 
> <head>
> .
> .
>   <script type="text/javascript" src="/js/subroutines.js"></script>
> </head>
> 
> <body>
> .
> .
> .

<script type='text/javascript'>

>   createNavigation();

</script>

> .
> .
> 
> </body
> 
> Nothing shows, 

I doubt that, a line of dots will show.
Please be exact in your observations

> any help would be appreciated. 
> -Rich
> 



-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


#18899

FromRich Rohde <rich@richware.net>
Date2013-03-14 15:34 -0700
Message-ID<a6312d94-a064-4a13-84f1-8d2ac00378d2@googlegroups.com>
In reply to#18898
On Thursday, March 14, 2013 2:23:09 PM UTC-7, Evertjan. wrote:
> Rich Rohde wrote on 14 mrt 2013 in comp.lang.javascript:
> 
> 
> 
> > I'm having somewhat of a problem.
> 
> > 
> 
> > Objective: include common html code in several html pages. should be
> 
> > simple. 
> 
> > 
> 
> > Created: subroutines.js with
> 
> 
> 
> 
> 
> As a newbee, do not use js files,
> 
> but put your js-code in the HTML-file header part.
> 
> 
> 
> This eases debugging.
> 
> 
> 
> What is the sense of seperate files, 
> 
> except when you want them cached on the client, 
> 
> something you will not want when debugging.
> 
> 
> 
> Or when you are so sure of the code's perfection, 
> 
> that you use them in different html-pages.
> 
> 
> 
> > 
> 
> > 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
> 
> 
> 
> 'Result' is not a js-command, you will get an error here.
> 
> 
> 
> Debugging would give this away.
> 
> 
> 
> >}
> 
> > 
> 
> > 
> 
> > In my HTML I have:
> 
> > 
> 
> > <head>
> 
> > .
> 
> > .
> 
> >   <script type="text/javascript" src="/js/subroutines.js"></script>
> 
> > </head>
> 
> > 
> 
> > <body>
> 
> > .
> 
> > .
> 
> > .
> 
> 
> 
> <script type='text/javascript'>
> 
> 
> 
> >   createNavigation();
> 
> 
> 
> </script>
> 
> I figured it out: Just <script>function_name</script>
> 
> > .
> 
> > .
> 
> > 
> 
> > </body
> 
> > 
> 
> > Nothing shows, 
> 
> 
> 
> I doubt that, a line of dots will show.
> 
> Please be exact in your observations
> 
> 
> 
> > any help would be appreciated. 
> 
> > -Rich
> 
> > 
> 
> 
> 
> 
> 
> 
> 
> -- 
> 
> Evertjan.
> 
> The Netherlands.
> 
> (Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


#18950

FromEric Bednarz <bednarz@fahr-zur-hoelle.org>
Date2013-03-20 01:05 +0100
Message-ID<m2obefx7dp.fsf@nntp.bednarz.nl>
In reply to#18898
"Evertjan." <exxjxw.hannivoort@inter.nl.net> writes:

> As a newbee, do not use js files,

What?

> but put your js-code in the HTML-file header part.

The what?
    
> This eases debugging.

I remember you having relatively dated (only by a decade or so) ideas
about JS debugging, so you are probably excused.

Newbees, on the other hand, are allowed to use a browser's developer
tools (Google Chrome's are excellent).

[toc] | [prev] | [next] | [standalone]


#18954

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2013-03-20 18:03 +0100
Message-ID<XnsA189B7B2A7710eejj99@194.109.133.133>
In reply to#18950
Eric Bednarz wrote on 20 mrt 2013 in comp.lang.javascript:

> "Evertjan." <exxjxw.hannivoort@inter.nl.net> writes:
> 
>> As a newbee, do not use js files,
> 
> What?
> 
>> but put your js-code in the HTML-file header part.
> 
> The what?
>     
>> This eases debugging.

This your idea of go to hell dot org?


> I remember you having relatively dated (only by a decade or so) ideas
> about JS debugging, so you are probably excused.
> 
> Newbees, on the other hand, are allowed to use a browser's developer
> tools (Google Chrome's are excellent).




-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


#18904

From"Jukka K. Korpela" <jkorpela@cs.tut.fi>
Date2013-03-15 08:04 +0200
Message-ID<khudhp$8bo$1@dont-email.me>
In reply to#18897
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/

[toc] | [prev] | [next] | [standalone]


#18909

FromJJ <jaejunks@nah.meh>
Date2013-03-15 20:48 +0000
Message-ID<XnsA18527CF5E7DEjj@0.0.0.18>
In reply to#18897
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.

[toc] | [prev] | [next] | [standalone]


#18911

FromDr J R Stockton <reply1300@merlyn.demon.co.uk.invalid>
Date2013-03-15 21:56 +0000
Message-ID<ppv8xlFOk5QRFwon@invalid.uk.co.demon.merlyn.invalid>
In reply to#18897
In comp.lang.javascript message <eee039e6-69a2-413d-bc99-f339dc1410e4@go
oglegroups.com>, Thu, 14 Mar 2013 14:05:36, Rich Rohde
<rich@richware.net> posted:

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

If the common HTML is syntactically complete, then it can be put into a
file and displayed in an iframe; the frame does not need to be [very?]
visible.

For example, the HTML of <http://www.merlyn.demon.co.uk/lagrdiff.htm>
is shown in <http://www.merlyn.demon.co.uk/essai-3c.htm>
and also in <http://www.merlyn.demon.co.uk/lagrhist.htm>, using
        <iframe src="lagrdiff.htm" style="width:99%; height:45ex;"> .

-- 
 (c) John Stockton, nr London, UK.  Mail via homepage.  Turnpike v6.05  MIME.
  Web  <http://www.merlyn.demon.co.uk/> - FAQqish topics, acronyms and links;
  Astro stuff via astron-1.htm, gravity0.htm ; quotings.htm, pascal.htm, etc.
 No Encoding. Quotes before replies. Snip well. Write clearly. Don't Mail News.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web