I would like a Javascript only solution.
This HTML only version does what I want:
But seemingly doing the same thing here in Javascript puts one div on top of another, rather than side-by-side.
What is missing, or what am I doing wrong, in the Javascript version? Thanks.
This HTML only version does what I want:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd"> <html><body> <div style="width: 1200px; height: 1000px;"> <div style="width: 50%; height: 80%; float: left;"> This is the left side. </div> <div style="width: 49%; height: 80%; float: right;"> This is the right side. </div> </div> </body></html>
But seemingly doing the same thing here in Javascript puts one div on top of another, rather than side-by-side.
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd"> <html> <script type="text/javascript"> function main() { var bodyObj, divMain, divLeft, divRight; bodyObj = document.getElementsByTagName("body")[0]; divMain = document.createElement("div"); divMain.style.width = "1200px"; divMain.style.height = "1000px"; bodyObj.appendChild(divMain); divLeft = document.createElement("div"); divLeft.style.width = "50%"; divLeft.style.height = "80%"; divLeft.style.float = "left"; divLeft.innerHTML = "This is the left side."; divMain.appendChild(divLeft); divRight = document.createElement("div"); divRight.style.width = "49%"; divRight.style.height = "80%"; divRight.style.float = "right"; divRight.innerHTML = "This is the right side."; divMain.appendChild(divRight); } </script> <body onload="main()"> </body></html>
Comment