Firefox and Opera Zoom In Zoom Out using javascrip

2019-07-23 15:24发布

问题:

Hi I want to achieve zoom in/out feature which is available in chrome and IE

For instance in IE I can easily set the zoom, percentage by using the following javascript code

document.style.zoom="20%";

How can I achieve the same in Firefox and Opera, any help,guideline is really appreciated.

回答1:

for firefox after version 3 atleast as far as i know :

Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator).getMostRecentWindow("navigator:browser").getBrowser().mCurrentBrowser.markupDocumentViewer.fullZoom = 3;

Launch the Javascript console by selecting Error Console from Firefox's Tools menu. Then, type the following into the code text box and click the Evaluate button. for 3x zoom u can change the number at the end for testing

So if the browser is FF i guess you can do this aint that sure though. Most probably you will need signed scripts http://www.mozilla.org/projects/security/components/signed-scripts.html