aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Change inline style with Javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Change inline style with Javascript" Watch "Change inline style with Javascript" New topic
Author

Change inline style with Javascript

Reese Doherty
Greenhorn

Joined: Dec 07, 2006
Posts: 8
I am truing to change the online style of all elements on a page with the following javascript

el = document.getElementsByTagName('*');
for (i=0; i<el.length; i++)
{
if(contains(el[i].style.cssText, 'xxx'))
{
alert('In if');
}
else
{
alert('In else');
}
}

However I am getting an Object expected JS error. Anyone have any idea what I am doing wrong?

Thanks
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
contains is not a method that I know of: http://developer.mozilla.org/en/docs/JavaScript_Methods_Index#C

Eric
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61769
    
  67

Reese, your code will be easier to read if you use UBB code tags. Please read this for more information.
[ April 26, 2007: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Change inline style with Javascript