javascript 反射 样式

 

 

代码:

 

 1 <html>
 2 <head>
 3     <title></title>
 4 </head>
 5 <body>
 6     <form id="myForm" >
 7     Hello World~
 8     </form>
 9     <script type="text/javascript">
10         function evaluateByStyle() {
11             var element = document.getElementById("myForm");
12             for (var p in _style) {
13                 element.style[p] = _style[p];
14             }
15         }
16         var _style = {
17            color:"#ffffff",
18            backgroundColor:"#ff0000",
19            borderWidth:"2px",
20            fontSize:"50px"
21         }
22 
23         window.load = evaluateByStyle(_style);
24     </script>
25 </body>
26 </html>
27 


 

结果:

 

 

 

 

附件:

 

JavaScript 支持的CSS 样式 参考表:

 

 

accelerator        "false"        String

background        ""        String

backgroundAttachment        ""        String

backgroundColor        ""        String

backgroundImage        ""        String

backgroundPosition        ""        String

backgroundPositionX        ""        String

backgroundPositionY        ""        String

backgroundRepeat        ""        String

behavior        ""        String

border        ""        String

borderBottom        ""        String

borderBottomColor        ""        String

borderBottomStyle        ""        String

borderBottomWidth        ""        String

borderCollapse        ""        String

borderColor        ""        String

borderLeft        ""        String

borderLeftColor        ""        String

borderLeftStyle        ""        String

borderLeftWidth        ""        String

borderRight        ""        String

borderRightColor        ""        String

borderRightStyle        ""        String

borderRightWidth        ""        String

borderSpacing        ""        String

borderStyle        ""        String

borderTop        ""        String

borderTopColor        ""        String

borderTopStyle        ""        String

borderTopWidth        ""        String

borderWidth        ""        String

bottom        ""        String

boxSizing        ""        String

captionSide        ""        String

clear        ""        String

clip        ""        String

color        ""        String

constructor        {...}        Object

content        ""        String

counterIncrement        ""        String

counterReset        ""        String

cssText        ""        String

cursor        ""        String

direction        ""        String

display        ""        String

emptyCells        ""        String

filter        ""        String

font        ""        String

fontFamily        ""        String

fontSize        ""        String

fontStyle        ""        String

fontVariant        ""        String

fontWeight        ""        String

height        ""        String

imeMode        ""        String

layoutFlow        ""        String

layoutGrid        ""        String

layoutGridChar        ""        String

layoutGridLine        ""        String

layoutGridMode        ""        String

layoutGridType        ""        String

left        ""        String

letterSpacing        ""        String

lineBreak        ""        String

lineHeight        ""        String

listStyle        ""        String

listStyleImage        ""        String

listStylePosition        ""        String

listStyleType        ""        String

margin        ""        String

marginBottom        ""        String

marginLeft        ""        String

marginRight        ""        String

marginTop        ""        String

maxHeight        ""        String

maxWidth        ""        String

minHeight        ""        String

minWidth        ""        String

msBlockProgression        ""        String

msInterpolationMode        ""        String

orphans        ""        String

outline        ""        String

outlineColor        ""        String

outlineStyle        ""        String

outlineWidth        ""        String

overflow        ""        String

overflowX        ""        String

overflowY        ""        String

padding        ""        String

paddingBottom        ""        String

paddingLeft        ""        String

paddingRight        ""        String

paddingTop        ""        String

pageBreakAfter        ""        String

pageBreakBefore        ""        String

pageBreakInside        ""        String

pixelBottom        0        Number

pixelHeight        0        Number

pixelLeft        0        Number

pixelRight        0        Number

pixelTop        0        Number

pixelWidth        0        Number

posBottom        0        Number

posHeight        0        Number

position        ""        String

posLeft        0        Number

posRight        0        Number

posTop        0        Number

posWidth        0        Number

quotes        ""        String

right        ""        String

rubyAlign        ""        String

rubyOverhang        ""        String

rubyPosition        ""        String

scrollbar3dLightColor        ""        String

scrollbarArrowColor        ""        String

scrollbarBaseColor        ""        String

scrollbarDarkShadowColor        ""        String

scrollbarFaceColor        ""        String

scrollbarHighlightColor        ""        String

scrollbarShadowColor        ""        String

scrollbarTrackColor        ""        String

styleFloat        ""        String

tableLayout        ""        String

textAlign        ""        String

textAlignLast        ""        String

textAutospace        ""        String

textDecoration        ""        String

textDecorationBlink        false        Boolean

textDecorationLineThrough        false        Boolean

textDecorationNone        false        Boolean

textDecorationOverline        false        Boolean

textDecorationUnderline        false        Boolean

textIndent        ""        String

textJustify        ""        String

textJustifyTrim        ""        String

textKashida        ""        String

textKashidaSpace        ""        String

textOverflow        ""        String

textTransform        ""        String

textUnderlinePosition        ""        String

top        ""        String

unicodeBidi        ""        String

verticalAlign        ""        String

visibility        ""        String

whiteSpace        ""        String

widows        ""        String

width        ""        String

wordBreak        ""        String

wordSpacing        ""        String

wordWrap        ""        String

writingMode        ""        String

zIndex        0        Number

zoom        ""        String

 

posted @ 2010-07-21 10:40  iDEAAM  阅读(258)  评论(0编辑  收藏  举报