Solved

Can a web page adjust a browser's zoom level?

Posted on 2011-03-16
4
757 Views
Last Modified: 2012-05-11
Internet explorer has a zoom control in the lower right corner.  Is there a way for a web page to make itself fit the view area by "auto-adjusting" this control in Internet Explorer?
0
Comment
Question by:RandyTommy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 9

Assisted Solution

by:jkofte
jkofte earned 100 total points
ID: 35154302
actually, there is no way to detect it with javascript.
but there might be an alternative solution but this can take some time to do.

normally if you zoom in or zoom out in browser, if your content is defined by percentage the ratio of distance between the content remains the same. But if you have one content defined by percentage and one content defined by pixels, this ratio should change when you zoom in or out. by measuring the difference, you can calculate the zoom percentage of the browser.
0
 
LVL 11

Accepted Solution

by:
remixedcat earned 400 total points
ID: 35154826
There are also scripts that will perform this action as well. There also are some that do not use the browser's zoom, however they scale the content and use CSS to re-render the elements.
0
 

Assisted Solution

by:RandyTommy
RandyTommy earned 0 total points
ID: 35159234
I did not know bout the ZOOM function in javascript, which provides the real answer.
Remixedcat's comment led me to do the right Google search, which lead to the function below.

        function window_onresize()
        {
            //  NOTE:  Resizes the document to fit the windows view area.
            //  Replace 1034 and 650 with your actual document dimentions.)

            var w = document.documentElement.clientWidth / 1034;
            var h = document.documentElement.clientHeight / 650;
            if (w < h)
                document.body.style.zoom = w;
            else
                document.body.style.zoom = h;
        }

<body onresize="return window_onresize()" >
0
 

Author Closing Comment

by:RandyTommy
ID: 35187421
Also, It was good to know from jkofte that there is no way to detect zoom with Javascript.  (100 points)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface There are many applications where some computing systems need have their system clocks running synchronized within a small margin and eventually need to be in sync with the global time. There are different solutions for this, i.e. the W3…
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
Shows how to create a shortcut to site-search Experts Exchange using Google in the Chrome browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch the Search Engine Menu: In chrome, via you…
How to create a custom search shortcut to site-search Experts Exchange using Google in the Firefox browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch your Bookmark Menu: Press 'Ctrl +…

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question