以编程方式为网页设置默认缩放?

Is it possible to set the default zoom level on a site? For instance, could I code my site in such as a way that it is zoomed to 125% when a user opens it?

My website body has this code

<body ID="phpbb" class="section-{SCRIPT_NAME} {S_CONTENT_DIRECTION}"> 

How to put this zoom code inside?

Add zoom: 125%; to body style

body {
color: #536482;
background-color: white;
zoom: 125%;
}

You might want to check the zoom CSS attribute. Bear in mind however that it is part of CSS3 and that, therefore, you might find it to behave oddly on old IEs. This is also completely separate from the interface zoom.

This does not directly answer your question, but is an alternative that I recommend considering.

If you use relative sizing for your page (such as em), then you can set the base size of the site in one place, and the whole page will scale up and down accordingly.

For instance, if I want 125% of default size:

body { font-size: 1.25em }

Then, suppose I want a reasonable amount of margin around a header <div>:

#header { margin: 1em }

If I then go back and change that base size on the body to something else, the margin on my header will scale with it. If you do your entire page in relative units, this becomes very easy to do.

webView.setInitialScale((int) getResources().getDimension(R.dimen._50sdp));
                            webView.getSettings().setLoadsImagesAutomatically(true);
                            webView.getSettings().setJavaScriptEnabled(true);
                            webView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
                            webView.loadDataWithBaseURL(null,htmlContent,"text/html","UTF-8", null);
                            webView.getSettings().setBuiltInZoomControls(true);
                            webView.getSettings().setSupportZoom(true);
                            webView.getSettings().setDisplayZoomControls(true);
                            webView.getSettings().setDefaultZoom(WebSettings.ZoomDensity.FAR);