[Javascript] text input field acting up

Hassan Schroeder hassan at webtuitive.com
Fri Sep 3 15:34:21 CDT 2004


Innerlab wrote:

> This is more of a CSS question, but I am not in any mailing list for that. In any case, the style changes I am dealing with now are
> quite dynamic and involve javascript.
> 
> Below is an example of image parameters that can be changed using javascript.
> 
> var jsPath = "img/myimage.jpg"
> var jsHeight = 20
> var jsWidth = 200
> document.write('<img src="'+jsPath +'" width="'+jsHeight +'" height="+jsWidth +" />');
> 
> Now, how can I change such parameters when the image it's used as a background ?
> 
> Example:
> div.mydiv {background-image:url(img/bkg_01.jpg);}
> 
> Any ideas?

Lots :-)

1/ it'd be good to start a new thread (with a relevant title) when
    you change the subject

2/ the CSS spec is your friend; it shows the standard properties
    available through the DOM -- <http://www.w3.org/TR/CSS21/>;
    in this case, background images don't have a height and width
    property, if you were looking for those specifically

3/ dude, it's the *21st century* :-) -- why use `document.write()`
    when you can manipulate directly with the DOM? e.g,
      document.getElementsByTagName("body")[0].style.backgroundImage =
         "url(" + jsPath + ")";

4/ Mozilla's DOM inspector is a good way to see both standard and
    Moz-specific properties, and their current (computed) style

FWIW!
-- 
Hassan Schroeder ----------------------------- hassan at webtuitive.com
Webtuitive Design ===  (+1) 408-938-0567   === http://webtuitive.com

                           dream.  code.





More information about the Javascript mailing list