[Javascript] span section

Muchacho, Laurent (TWIi London) LMuchacho at twii.net
Tue Nov 12 07:09:30 CST 2002


why it's wrong ?

look at the code what happen if you try to write something in a span when
the span doesn't exist (not complicated to understand) you can't access an
element in the page before is as been built by the browser .

Laurent 

-----Original Message-----
From: Andrzej Wróblewski [mailto:alfwro at wp.pl]
Sent: 12 November 2002 12:56
To: javascript at LaTech.edu
Subject: Re: [Javascript] span section


> You probably need to use an onload event
> 
> <body onload=javascript:writeIt()>
> 
> then
> function writeIt()
> {
> document.getElementById("mySpan").innerHTML="Whatever" ;
> }

thank You it works !!

But ... tell me why this is wrong:
<HTML>
<HEAD>
<script>
document.getElementById("myspan").innerHTML="Whatever" ;
</SCRIPT>
</HEAD>
<BODY>
<span id="myspan">
</span>
</BODY>
</HTML>

debugger return error:   'document.getElementById(...)' is empty or is 
not an object

Why's that?
Regards
andrzej

> > If I create a span section i the <body>:
> > 
> > <html><head>
> > <script>
> > var textToInsertSpan = "Some text"
> > document.spanName?????????????? = textToInsertSpan
> > </script>
> > </head><body>
> > <span name="spanName">
> > </span>
> > </body></html>
> > 
> >  how using JavaScript in the <head> section put text into <span> 
> > sect.? 
> > 
> > 
_______________________________________________
Javascript mailing list
Javascript at LaTech.edu
https://lists.LaTech.edu/mailman/listinfo/javascript


DISCLAIMER - The preceding e-mail message (including any attachments)
contains information that may be confidential, may be protected by the
attorney-client or other applicable privileges, or may constitute non-public
information.  It is intended to be conveyed only to the designated
recipient(s) named above.  If you are not an intended recipient of this
message, or have otherwise received it in error, please notify the sender by
replying to this message and then delete all copies of it from your computer
system.  Any use, dissemination, distribution, or reproduction of this
message by unintended recipients is not authorized and may be unlawful. The
contents of this communication do not necessarily represent the views of
this company.



More information about the Javascript mailing list