-1

How would I add a js function that zooms the webpage to 125% on loading?

I found a way to do it with buttons, but I want the webpage to auto-zoom on loading.

<button onclick="body.style.zoom='150%'">Zoom 150%</button>

I tried to put it into the body tag like the code below but it did not work...

<body onload="body.style.zoom='150%'">

Thanks.

2 Answers2

2

simply ditch the js and use css

<body style="zoom:150%;">

<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body style="zoom:150%;">
<h1>My First Heading</h1>
<p>My first paragraph.</p>

</body>
</html>
1

css solution:

body{
    zoom: 125%;
}

inline javascript solution:

<button
    onclick="document.getElementsByTagName('body')[0].style.zoom='150%'"
>Click to zoom
</button>
Vincent Menzel
  • 1,040
  • 1
  • 6
  • 17