Forum Moderators: open
window.onload = function()
{
document.body.appendChild( rectangle(200,100,250,250,"blue","red") )
}function rectangle(w,h,x,y,bg,bCol)
{
var rect = document.createElement("div");
var style = rect.style;
style.width = w +"px";
style.height = h +"px";
style.left = x +"px";
style.top = y +"px";
style.backgroundColor = bg;
style.borderColor = bCol;
// fixed
style.position = "absolute";
style.borderStyle = "solid"
style.borderWidth = 1;
return rect
}
You'll have to post your new version of the function.
> where can i get others similar example?
Google: DHTML beginners tutorial [google.com]
I would recommend concentrating as much as possible on learning core Javascript first.
This site is good: [howtocreate.co.uk...]
function rectangle(w,h,x,y,bg,bCol) {
var rect = document.createElement("div");
var style = rect.style;
style.width = w +"px";
style.height = h +"px";
style.left = x +"px";
style.top = y +"px";
style.backgroundColor = bg;
style.borderColor = bCol; // fixed
style.position = "absolute";
style.borderStyle = "solid"
style.borderWidth = 1;
style.fontSize = "18px";
style.font = "Arial";
rect.innerHTML = "hello";
return rect }