|
I found out myself:
var newdiv = document.createElement('div');
var divIdName = 'testDiv';
newdiv.setAttribute('id',divIdName);
newdiv.style.width = "300px";
newdiv.style.height = "300px";
newdiv.style.left = "300px";
newdiv.style.top = "300px";
newdiv.style.position = "absolute";
newdiv.style.background = "#00C";
newdiv.style.border = "4px solid #000";
newdiv.innerHTML = 'Test Div';
document.body.appendChild(newdiv);
|
|
Expert:
|
david
|
|
Date:
|
Sep 12, 2006
|
|
Time:
|
09:16
|
|
|
|
Votes: Good (0) | Bad (0) Login to rate this answer
|
|
|
good work...now give me your points...lol
|
|
Expert:
|
multani.sarbjit
|
|
Date:
|
Sep 12, 2006
|
|
Time:
|
11:58
|
|
|
|
Votes: Good (0) | Bad (0) Login to rate this answer
|
|
|
Ok, good enough david, but what I usually do is to define the DIV in the html code like this (example with some of your attributes):
<div name="testDiv" id="divID" style="width: 300px; height: 300px; left: 300px; top: 300px; position: absolute; display: none">
Test Div
</div>
Note the "display: none" which hides it initially.
When you want to show it, just execute
document.getElementById("divID").style.display = "";
You can also create copies of it in javascript and - of course - hide it again.
I think it makes it simpler to keep layout in the html file and only let javascript handle execution.
Jakob
|
|
Expert:
|
jgivoni
|
|
Date:
|
Sep 13, 2006
|
|
Time:
|
15:17
|
|
|
|
Votes: Good (0) | Bad (0) Login to rate this answer
|
|
|
Thanks, Jakob, but I needed the complete dynamic approach since it will be used on different html-pages without me being able to alter the html on beforehand.
|
|
Expert:
|
david
|
|
Date:
|
Sep 20, 2006
|
|
Time:
|
11:25
|
|
|
|
Votes: Good (0) | Bad (0) Login to rate this answer
|
|
|
|
|
|
|
This question has been answered, and points have been rewarded to the following experts:
You're welcome however to comment or give additional information or if you wish, you have the ability to write an Answer Summary for this question by clicking on the "Answer Summaries" Tab.
|
|