1

I am trying write a Javascript function which runs on a button click event in SAP WEBI, which makes the browser zoom to 80%.

I am trying to use this code which works in case of a standard website (it does not use browser zoom but actually zooms in on the element which the button is in, however in the case of a webi it actually does nothing)

Script:

function fullscreen() {
    document.body.style.zoom = "80%";
}

HTML:

<button id="1" onClick="fullscreen()">full screen view</button>

Any help on how I could make the browser zoom back to 80% scale in SAP WEBI?

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48

3 Answers3

1

Use the decimal value not the percentage

 document.body.style.zoom = 0.8

see this Post

finder2
  • 842
  • 1
  • 11
  • 30
  • Thank you seems to work although I've noticed the problem should happen with IE. looks like in ie case the API does not take in consideration javascript codes – András Czeitner Aug 02 '18 at 06:17
0

I'm not sure if there's any way to Zoom-in or Zoom-out your browser this way, some browsers provide their APIs for the purpose but I'm not sure.

One way I can suggest is to zoom-out your entire DOM by using Javascript

document.body.style.zoom=1.0;
this.blur();

1.0 means 100%

0.8 means 80% (Your case)

150% would be 1.5

1000% would be 10.0

and so on.

this.blur() means that the curser, maybe you selected an input field, looses focus of every select item.(Refrence)

Wasif Ali
  • 886
  • 1
  • 13
  • 29
  • Thank you seems to work although I've noticed the problem should happen with IE. looks like in ie case the API does not take in consideration javascript codes But nevertheless I will use your solution in chrome case. – András Czeitner Aug 02 '18 at 06:18
  • Have you tried it with IE? Zoom is actually a CSS3 property and works fine with IE. – Wasif Ali Aug 02 '18 at 07:05
  • Yeah yeah. Sadly it worked on chrome case but in IE case totally disregarded it. Maybe because of the WEBI API – András Czeitner Aug 02 '18 at 07:27
  • Well I haven't tested it with WEBI, maybe that is the issue. I'll give it a try and will let you know. – Wasif Ali Aug 02 '18 at 09:18
  • Thank you :) It can happen that I've done something wrong. I am quite new to SAP webintelligence therefore mistakes can be made but as I said worked in chrome so I am quessing it has something to do with IE. – András Czeitner Aug 02 '18 at 10:15
0

first you should know that zoom is a non-standard property, use transform instead

Non-standard This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.

zoom

you could use transform

document.body.style.webkitTransform =         
  document.body.style.msTransform =          
  document.body.style.transform = 'scale(5)';
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Consequuntur similique cumque fugiat omnis quisquam ex harum. Quisquam ea velit architecto qui illum esse nesciunt earum nisi in voluptas ratione voluptatum!</p>
  • Thank you seems to work although I've noticed the problem should happen with IE. looks like in ie case the API does not take in consideration javascript codes – András Czeitner Aug 02 '18 at 06:18