Wednesday, April 7, 2010

CSS style attributes in Javascript

We often confused when using style attributes in java script.
I below listed the attribute names in java script equivalent to css.

line-height ---- lineHeight
text-align ---- textAlign
text-decoration ---- textDecoration
text-indent ---- textIndent
text-transform ---- textTransform

vertical-align ---- verticalAlign

font-family ---- fontFamily
font-style ---- fontStyle
font-variant ---- fontVariant
font-weight ---- fontWeight

list-style ---- listStyle

color ---- color
background-color ---- backgroundColor

margin-top ---- marginTop
margin-right ---- marginRight
margin-bottom ---- marginBottom
margin-left ---- marginLeft

Using indexof in Javascript

Hi all,
You know well about -

indexof() returns the position of first occurrence of a specified value.


window.self.location returns the path of the window.



<script type="text/javascript">
var url = ''+ window.self.location;
if (url.indexOf('yoursite.com')!=-1)
{
document.getElementById('wrapper').style.backgroundColor ='green';
//You can modify here
}
</script>