views:

545

answers:

3

Hi, I would like to know how zoom property can be controlled through javascript, like div.style.top , how to specify for zoom ?

A: 

It doesn't exists it seems. Here's a table with (I think all) css properties to javascript. http://codepunk.hardwar.org.uk/css2js.htm

Robin
Thanks for the link , useful . unfortunately no zoom as u have mentioned!
sat
+1  A: 

It is a property of style, but it's not supported by all browsers. It's a non-standard Microsoft extension of CSS that Internet Explorer implements. It is accessed like this:

div.style.zoom
zombat
I mainly test in Safari , In safari if I give zoom value in css style, it works but not div.style.zoom=200% or 200+"%" or 200 or "200%".
sat
zoom is a non-standard property, so the webkit engine doesn't recognize it.
zombat
+4  A: 

The Firefox & Chrome (Webkit) equivalents to the IE-specific zoom property are, respectively, -moz-transform and -webkit-transform.

A sample code would be:

.zoomed-element {
    zoom: 1.5;
    -moz-transform: scale(1.5);
    -webkit-transform: scale(1.5);
}

You'd have to be a bit more careful with Javascript (test for existence first), but here's how you'd manipulate them:

el.style.zoom = 1.5;
el.style.MozTransform = 'scale(1.5)';
el.style.WebkitTransform = 'scale(1.5)';
K Prime
el.style.zoom = 1.5;Works cool, I was giving value in wrong way !, What are the acceptable numbers for zoom ?? Is it between 1 to 2 and if I mention 1.5 is it 150 % ?
sat
I'm not sure if zoom levels are limited. And yes, 1.5 => 150%
K Prime
1 == 100%, you can go beyond 2.
Tracker1
I am using above suggestion,now how to zoom back to original size ? lil confused here , documentation says have to use value less than 1 to zoom out , and how to scale back to original size ??
sat
Original size should be 1
K Prime