Asohk.com
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Javascript code snippet to create a div dynamically in Java

Go down

Javascript code snippet to create a div dynamically in Java Empty Javascript code snippet to create a div dynamically in Java

Post  Admin Sat Aug 02, 2008 12:03 pm

Code

function creatediv(id, html, width, height, left, top) {

var newdiv = document.createElement('div');
newdiv.setAttribute('id', id);

if (width) {
newdiv.style.width = 300;
}

if (height) {
newdiv.style.height = 300;
}

if ((left || top) || (left && top)) {
newdiv.style.position = "absolute";

if (left) {
newdiv.style.left = left;
}

if (top) {
newdiv.style.top = top;
}
}

newdiv.style.background = "#00C";
newdiv.style.border = "4px solid #000";

if (html) {
newdiv.innerHTML = html;
} else {
newdiv.innerHTML = "nothing";
}

document.body.appendChild(newdiv);

}
Admin
Admin
Admin
Admin

Posts : 60
Join date : 2007-12-17

https://asohk.forummotion.com

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum