SearchSearch   

has no properties error

 
   Webmaster Forums (Home) -> Javascript RSS
Next:  Simulate Mouse Event  
Author Message
Jon Paal [MSMD]

External


Since: Aug 08, 2007
Posts: 2



(Msg. 1) Posted: Wed Aug 08, 2007 12:14 pm
Post subject: has no properties error
Archived from groups: comp>lang>javascript (more info?)

I get common error "document.getElementById("grid") has no properties"

what's missing here ?

<script language="javascript">
document.getElementById('grid').innerHTML = "xxx";
</script>

<div id="grid">div>
Back to top
Joe Attardi

External


Since: May 11, 2007
Posts: 4



(Msg. 2) Posted: Wed Aug 08, 2007 3:27 pm
Post subject: Re: has no properties error
Archived from groups: per prev. post (more info?)

Jon Paal [MSMD] wrote:
> I get common error "document.getElementById("grid") has no properties"
>
> what's missing here ?
>
> <script language="javascript">
> document.getElementById('grid').innerHTML = "xxx";
> </script>
>
> <div id="grid">div>

If that is your code, verbatim, it's because the script gets executed
before the <div> is created and added to the DOM. So when
document.getElementById('grid') is called, it returns undefined.

You want the script moved after the <div>, or make it get called after
the document is done loading.


--
Joe Attardi
jattardi.DeleteThis@gmail.com
Back to top
Jon Paal [MSMD]

External


Since: Aug 08, 2007
Posts: 2



(Msg. 3) Posted: Wed Aug 08, 2007 3:27 pm
Post subject: Re: has no properties error
Archived from groups: per prev. post (more info?)

thanks

"Joe Attardi" <jattardi RemoveThis @gmail.com> wrote in message news:nMCdndHTILSxhCfbnZ2dnUVZ_tfinZ2d@comcast.com...
> Jon Paal [MSMD] wrote:
>> I get common error "document.getElementById("grid") has no properties"
>>
>> what's missing here ?
>>
>> <script language="javascript">
>> document.getElementById('grid').innerHTML = "xxx";
>> </script>
>>
>> <div id="grid">div>
>
> If that is your code, verbatim, it's because the script gets executed before the <div> is created and added to the DOM. So when
> document.getElementById('grid') is called, it returns undefined.
>
> You want the script moved after the <div>, or make it get called after the document is done loading.
>
>
> --
> Joe Attardi
> jattardi RemoveThis @gmail.com
Back to top
vunet.us

External


Since: Jun 04, 2007
Posts: 65



(Msg. 4) Posted: Wed Aug 08, 2007 7:26 pm
Post subject: Re: has no properties error
Archived from groups: per prev. post (more info?)

Is this how you write div within the code? It is missing </ if you
look closely.

> <div id="grid">div>

VUNET
www.vunet.us
www.worldincatalog.com
Back to top
dave

External


Since: Jun 13, 2007
Posts: 5



(Msg. 5) Posted: Wed Aug 08, 2007 7:51 pm
Post subject: Re: has no properties error
Archived from groups: per prev. post (more info?)

On Aug 8, 11:14 am, "Jon Paal [MSMD]" <Jon nospam Paal @ everywhere
dot com> wrote:
> I get common error "document.getElementById("grid") has no properties"
>
> what's missing here ?
>
> <script language="javascript">
> document.getElementById('grid').innerHTML = "xxx";
> </script>
>
> <div id="grid">div>

validate that piece of HTML and you'll see the problem
Back to top
Randy Webb

External


Since: Aug 24, 2004
Posts: 4981



(Msg. 6) Posted: Wed Aug 08, 2007 7:51 pm
Post subject: Re: has no properties error
Archived from groups: per prev. post (more info?)

dave said the following on 8/8/2007 3:51 PM:
> On Aug 8, 11:14 am, "Jon Paal [MSMD]" <Jon nospam Paal @ everywhere
> dot com> wrote:
>> I get common error "document.getElementById("grid") has no properties"
>>
>> what's missing here ?
>>
>> <script language="javascript">
>> document.getElementById('grid').innerHTML = "xxx";
>> </script>
>>
>> <div id="grid">div>
>
> validate that piece of HTML and you'll see the problem
>

Actually, he won't. Browsers will error correct it and close the div
element. The problem is trying to access an element before it exists in
the DOM. Closing the div tag and testing it will confirm it.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Back to top
bujnos.bujnowski

External


Since: Aug 16, 2007
Posts: 1



(Msg. 7) Posted: Thu Aug 16, 2007 5:22 am
Post subject: Re: has no properties error
Archived from groups: per prev. post (more info?)

On 8 Sie, 15:14, "Jon Paal [MSMD]" <Jon nospam Paal @ everywhere dot
com> wrote:
> I get common error "document.getElementById("grid") has no properties"
>
> what's missing here ?
>
> <script language="javascript">
> document.getElementById('grid').innerHTML = "xxx";
> </script>
>
> <div id="grid">div>

for sure closing div tag is incomplete Smile
Back to top
Display posts from previous:   
       Webmaster Forums (Home) -> Javascript
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum