
createElement does not support inline style
The createElement javascript call and subsequent appendChild call should accept the inline style attribute format. In the first example below five lines of code are required when the second example below creating the same element uses the inline style format only requires one line. Additionally, it is necessary to know the different attribute names when switching between style formats.
The goal should be to use inline style format with every element. All other style format usage should be discouraged and marked as deprecated.
The inline style format supports "vertical" code compression by allowing all style attributes to be set all on one line of code.
dataFrame = document.createElement("iframe"); dataFrame.id = "plotFrame"; dataFrame.name = "displayData"; dataFrame.style.border = "1"; dataFrame.style.top = "100px"; dataFrame.style.left = "0px"; dataFrame.style.width = "1100px"; dataFrame.style.height = "730px"; document.body.appendChild(dataFrame);
//document.writeln("<iframe id='plotFrame' style='position:absolute; border:1; top:100px; left:100px; width:1100px; height:730px;'></iframe>");
Modified
Chosen solution
The preferred way is to use DOM methods to add elements afterward and not use writeln as the latter may not always work properly even if it is easier to write down.
You can probably still use setAttribute("style", ""); to set all style rules for that iframe in one line.
Read this answer in context 👍 1All Replies (1)
Chosen Solution
The preferred way is to use DOM methods to add elements afterward and not use writeln as the latter may not always work properly even if it is easier to write down.
You can probably still use setAttribute("style", ""); to set all style rules for that iframe in one line.