Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can <DIV ID="XYZ"></DIV> be created in JavaScript 1

Status
Not open for further replies.

Dragonfish

Programmer
Apr 25, 2001
62
UG
Happy Christmas Everyone,

can I create <DIV ID=&quot;XYZ&quot;></DIV> strait out of JavaScript without haveíng to write them in the body area first. With tabe-tags that works fine:-
document.write(&quot;<Table.......>&quot;);.
docoment.write(&quot;<DIV ID=&quot;XYZ&quot;></DIV>&quot;); does´nt work - how naive of me! Can anyone help???

Thanks
DavidinGermany
 
try this...
document.write(&quot;<DIV ID=\&quot;XYZ\&quot;></DIV>&quot;);
 
I tried it - did´nt work. I noticed I made a small error in my thread:
docoment.write(&quot;<DIV ID=&quot;XYZ&quot;></DIV>&quot;);
should have been:
docoment.write(&quot;<DIV ID='XYZ'></DIV>&quot;);

Can you tell me what \&quot;XYZ\&quot; should have done. I´ve ploughed through so much literature and have´nt found anything which suggests that:
docoment.write(&quot;<DIV ID='XYZ'></DIV>&quot;);
might or should work of if there´s another way of writing (&quot;<DIV ID='XYZ'></DIV>&quot;);

Thanks DavidinGermany
 
\&quot; is the escaped version of &quot; javascript will give you errors if you use nested &quot; the \&quot; gets around that. so would:
document.write(&quot;<div id='xyz'></div>&quot;);

i use document.write(&quot;<div id=&quot; + variable + &quot;></div>&quot;); to write mine in my dhtml pages and it works fine.
 
if you are trying to create this div after the page has loaded, you are going to have to use innerHTML:

document.body.innerHTML+=&quot;<div id='xyz'></div>&quot;; Robert Carpenter
questions? comments? thanks? email me!
linkemapx@hotmail.com
Icq: 124408594
online.dll

AIM & MSN: robacarp
 
Wow Super fantastic - Robert god bless your little cotton socks. It worked in IE. You´ve no idea - I´ve been tearing my hair out for weeks over this. I´ll get back to you later.

TTTTTTHHHHHAAAAANNNNNKKKKKSSSSSS
DavidinGermany
 
David-
glad to help!

now, you just have to remember that so you wont loose anymore hair ;-)

merry christmas to all Robert Carpenter
questions? comments? thanks? email me!
linkemapx@hotmail.com
Icq: 124408594
online.dll

AIM & MSN: robacarp
 
Now I know I´m pushing my luck here, but can I do the same thing with NS starting with NS4.x, Syntax ???????

Come on guys & girls I kkknnnooo can do it!
DavidinGermany
And thanks to everyone who helps and everyone who makes this a great website - Happy new year !
 
about ns4x:
div - nope, layer - yup

var theOne=new Layer(width,parent)
//width - a number
//parent - none or window or ref to another layer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top