JavaScript and client side scripting.
Moderator: General Moderators
-
tecktalkcm0391
- DevNet Resident
- Posts: 1030
- Joined: Fri May 26, 2006 9:25 am
- Location: Florida
Post
by tecktalkcm0391 »
I have this, but I am getting an error with the getNextSibling:
Code: Select all
new_div = document.createElement("div");
insert= document.getElementById("body");
document.body.insertBefore(new_div, insert.getNextSibling());
Code: Select all
<body><!-- insert div here --> </body>
Any help?
-
feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
Post
by feyd »
I would guess your call to getElementById() returned "undefined."
-
tecktalkcm0391
- DevNet Resident
- Posts: 1030
- Joined: Fri May 26, 2006 9:25 am
- Location: Florida
Post
by tecktalkcm0391 »
yeah i figured that out just after posting, I am now using:
Code: Select all
insert= document.getElementByTagName("body");
But still getting errors.
-
feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
Post
by feyd »
If memory serves, there is no getElementByTagName() method. getElementsByTagName() does exist however, but you could just use document.body.