Zoom text only in web pages with Opera
Saturday, 12. May 2007, 15:17:08
You can of course go into Tools -> Preferences -> Advanced -> Fonts and set the Minimum font size to something appropriate so that text never gets smaller than a certain size. Mine is at 11 pixels now. But sometimes you want to zoom text on pages for small periods, or only on certain pages. The solution is a simple User Javascript.
Download the zoom-text.js script and put it any folder you prefer, I use ~/.opera/userjs/ on my Linux laptop. I have already also told Opera to run User Javascript that are located in that drawer, by going to Tools -> Preferences -> Advanced -> Content -> Javascript Options and putting ~/.opera/userjs/ in the User Javascript files field.

Now just go to any page, and you should see a little icon at the bottom right of the page. Click on this icon and you will get a box containing a "zoom in", "zoom out" and a "reset" button to play with. The script will automatically adjust the size the next time you visit the same domain to match the size you altered it to the previous visit.
















Maulkin # 9. May 2007, 06:48
Thank you very much!
Medium # 13. May 2007, 17:32
Thank you, Nicolas!
nicomen # 14. May 2007, 05:44
zoomIcon.style.fontSize = "12px";
zoomControls.style.fontSize = "12px";
You can try forcing another pixel value like "20px" or play with "1em", "1.5em" or "2.5em".
If you just change the zoomIcon one, you might need to add some more space for the controls using:
zoomControls.style.margin = "0.5em";
Glad you liked it.
Medium # 16. May 2007, 23:33
It is interesting: some sites automatically are unwinding the window editable for zoom without click.
nicomen # 17. May 2007, 10:20
Medium # 19. May 2007, 18:21
And I'm sorry for my English... :/
nicomen # 21. May 2007, 05:19
Like this?
Medium # 21. May 2007, 07:32
nicomen # 21. May 2007, 11:30
Ah ok, you are saying the xoom "window" pops up without you clicking it? It doesn't happen to me, hm, that's weird...
Medium # 22. May 2007, 12:00
For the accuracy: it is necessary to use the search engine and only in results of searching one can see the automatically big icon from script.
And curiosity, try to add this search engine to your set...
nicomen # 24. May 2007, 10:59
Anonymous # 5. June 2007, 10:59
wargamez claims there is a bug in the anonymous posting, so I apologize for abusing the comments for testing... :-)
Anonymous # 5. June 2007, 11:03
http://www.dn.no/
Your script sticks to the flash stuff also, and on the very top flash it does not work.
nicomen # 5. June 2007, 12:49
Do you mean the scroll text part? Because the flash ads on the top are not own paes it seems.
If it's the scroll text part, I'm not sure I know how I should go forth to make it work in so small areas...
Anonymous # 5. June 2007, 13:40
Yes, thats what I meant :)
Anonymous # 25. April 2008, 18:13
Does this work for web pages that do not use .html? It does not seem to work on pages using .php or .shtml.
nicomen # 28. April 2008, 01:00
Anonymous # 6. April 2009, 23:23
Thanks, It works perfectly.
Anonymous # 16. June 2009, 13:12
Bless you, sir. Now I can use Opera 9.5.
Anonymous # 30. June 2009, 16:37
Thank you very much. Why doesn't opera have this feature built-in like firefox? It should be built-in in future release.
Anonymous # 8. August 2009, 11:06
Is it possible for this script to work cross sessions?
nicomen # 8. August 2009, 13:56
ericnott # 9. August 2009, 16:27
I do not know if there is any relation between the script and cookies of sites. On one hand, it remembers the setting of sites within a "session", and hence I guess it might have something to do with cookies. On the other hand, I do not delete cookies, and hence it should remember the settings if the scripts is to do with cookies.
I have used the script not long after you posted it on opera forums. I do know what kept from asking the question. Since beta version of Firefox 3, I had wished that I don't have to set the text zoom very session.
nicomen # 10. August 2009, 09:37
ericnott # 11. August 2009, 04:23
nicomen # 11. August 2009, 09:53
ericnott # 12. August 2009, 01:36
ericnott # 17. August 2009, 05:32
You had me tried hard understand more of cookies and javascripts. I think I have made it work. The script is as follows in the function setCookie:
function setCookie(cookieName, cookieValue) {
var days = 1000;
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
var path = "/";
var domain = location.hostname;
var secure = null;
document.cookie = escape(cookieName) + '=' + escape(cookieValue)
+ (expires ? expires : '')
+ (path ? '; PATH=' + path : '')
+ (domain ? '; DOMAIN=' + domain : '')
+ (secure ? '; SECURE' : '');
}
Is there anything wrong here? It is working so far, but not for all websites; eg, http://www.google.com and http://www.economist.com, which do not change the value of zoom level (zoom:0 all the time) while clicked plus or minus signs. Although the text sizes in pages are changed, they return to default zoom settings after pages are refreshed, even in the same "session". I am quite happy though. Thanks a lot...
Correct my mistakes if you do not mind. Thanks...
nicomen # 17. August 2009, 13:22
ericnott # 18. August 2009, 08:30
JavaScript - http://my.opera.com/nicomen/blog/2007/05/12/zoom-text-only-in-web-pages-with-opera?cid=9930321
User Javascript thread
Error:
name: ReferenceError
message: Statement on line 4: Undefined variable: WScript
stacktrace: n/a; see opera:config#UserPrefs|Exceptions Have Stacktrace
JavaScript
User JS compilation
Syntax error ...\UserJs\xerath-power-meenoo.js: line 532 of User JS script :
Expected token: ')'
})( window.opera
-----------------^
I did not even know opera grabs js from the net, and I don't have any clue what these two errors mean.
Take your time. It's not urgent.
nicomen # 18. August 2009, 10:48
nazartokar # 15. November 2009, 22:31
I've got two questions:
1. Can I make it remember settings even after Opera restarts? I've read that settings are been saved to the cookies. Cookies are enabled but zoom settings reset after every reload.
2. Can I change settings and zoom not only text but all over the page and save this setting for every site? Thanks!