Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #15165 > unrolled thread
| Started by | "FAQ server" <javascript@dotinternet.be> |
|---|---|
| First post | 2012-07-23 23:00 +0000 |
| Last post | 2012-08-05 12:55 -0400 |
| Articles | 4 — 4 participants |
Back to article view | Back to comp.lang.javascript
FAQ Topic - Why does my code fail to access an element? (2012-07-24) "FAQ server" <javascript@dotinternet.be> - 2012-07-23 23:00 +0000
Re: FAQ Topic - Why does my code fail to access an element? (2012-07-24) Robert Baer <robertbaer@localnet.com> - 2012-07-26 23:00 -0700
Re: FAQ Topic - Why does my code fail to access an element? (2012-07-24) Simona <simona@hotmail.xx> - 2012-07-27 08:06 +0200
Re: FAQ Topic - Why does my code fail to access an element? (2012-07-24) Dr.Kral@nyc.rr.com - 2012-08-05 12:55 -0400
| From | "FAQ server" <javascript@dotinternet.be> |
|---|---|
| Date | 2012-07-23 23:00 +0000 |
| Subject | FAQ Topic - Why does my code fail to access an element? (2012-07-24) |
| Message-ID | <500dd77a$0$285$14726298@news.sunsite.dk> |
-----------------------------------------------------------------------
FAQ Topic - Why does my code fail to access an element?
-----------------------------------------------------------------------
An element can only be accessed after it exists in the document.
Either:
A) include your script after the HTML element it refers to, or
B) use the `"load"` event to trigger your script.
Example A:
<div id="snurgle">here</div>
<script type="text/javascript">
// Don't forget var.
var snurgleEl = document.getElementById("snurgle");
window.alert(snurgleEl.parentNode);
</script>
Example B:
// In the HEAD.
<script type="text/javascript">
window.onload = function(){
var snurgleEl = document.getElementById("snurgle");
};
</script>
Other problems can include::
----------------------------
* invalid HTML
* two elements with the same `name` or `id`
* use of an unsafe name: http://jibbering.com/names/
The complete comp.lang.javascript FAQ is at
http://jibbering.com/faq/
--
The sendings of these daily posts are proficiently hosted
by http://www.pair.com.
[toc] | [next] | [standalone]
| From | Robert Baer <robertbaer@localnet.com> |
|---|---|
| Date | 2012-07-26 23:00 -0700 |
| Message-ID | <NcmdnQCHIeUTs4_NnZ2dnUVZ_judnZ2d@posted.localnet> |
| In reply to | #15165 |
FAQ server wrote:
> -----------------------------------------------------------------------
> FAQ Topic - Why does my code fail to access an element?
> -----------------------------------------------------------------------
>
> An element can only be accessed after it exists in the document.
>
> Either:
> A) include your script after the HTML element it refers to, or
> B) use the `"load"` event to trigger your script.
>
> Example A:
>
> <div id="snurgle">here</div>
> <script type="text/javascript">
> // Don't forget var.
> var snurgleEl = document.getElementById("snurgle");
> window.alert(snurgleEl.parentNode);
> </script>
>
> Example B:
>
> // In the HEAD.
> <script type="text/javascript">
> window.onload = function(){
> var snurgleEl = document.getElementById("snurgle");
> };
> </script>
>
> Other problems can include::
> ----------------------------
>
> * invalid HTML
>
> * two elements with the same `name` or `id`
>
> * use of an unsafe name: http://jibbering.com/names/
* Not Found
The requested URL /names/ was not found on this server.
>
>
> The complete comp.lang.javascript FAQ is at
> http://jibbering.com/faq/
>
[toc] | [prev] | [next] | [standalone]
| From | Simona <simona@hotmail.xx> |
|---|---|
| Date | 2012-07-27 08:06 +0200 |
| Message-ID | <aub4189n4empn82hsh3clbusip0odqprp2@4ax.com> |
| In reply to | #15195 |
On Thu, 26 Jul 2012 23:00:41 -0700, Robert Baer
<robertbaer@localnet.com> wrote:
>FAQ server wrote:
>> -----------------------------------------------------------------------
>> FAQ Topic - Why does my code fail to access an element?
>> -----------------------------------------------------------------------
>>
>> An element can only be accessed after it exists in the document.
>>
>> Either:
>> A) include your script after the HTML element it refers to, or
>> B) use the `"load"` event to trigger your script.
>>
>> Example A:
>>
>> <div id="snurgle">here</div>
>> <script type="text/javascript">
>> // Don't forget var.
>> var snurgleEl = document.getElementById("snurgle");
>> window.alert(snurgleEl.parentNode);
>> </script>
>>
>> Example B:
>>
>> // In the HEAD.
>> <script type="text/javascript">
>> window.onload = function(){
>> var snurgleEl = document.getElementById("snurgle");
>> };
>> </script>
>>
>> Other problems can include::
>> ----------------------------
>>
>> * invalid HTML
>>
>> * two elements with the same `name` or `id`
>>
>> * use of an unsafe name: http://jibbering.com/names/
>* Not Found
>The requested URL /names/ was not found on this server.
>
try
http://jibbering.com/faq/#accessElementBeforeDefined
http://jibbering.com/faq/names/
[toc] | [prev] | [next] | [standalone]
| From | Dr.Kral@nyc.rr.com |
|---|---|
| Date | 2012-08-05 12:55 -0400 |
| Message-ID | <899t18ts1c2u24fu9s726483chtn36ekf5@4ax.com> |
| In reply to | #15165 |
On Mon, 23 Jul 2012 23:00:02 +0000, "FAQ server"
<javascript@dotinternet.be> wrote in
<500dd77a$0$285$14726298@news.sunsite.dk>:
>
>* use of an unsafe name: http://jibbering.com/names/
This link is incorrect -- should be
http://jibbering.com/faq/names/
K.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web