When did javascript to Resize windows stopped working?
I just upgraded from Fx3.6.8 to Fx16.0.2, and now my javascript bookmarklets are not working. There doesn't appear to be any way to resize a window quickly by clicking a bookmark containing a javascript function, such as:
javascript:(function(){window.moveTo(22,33);window.resizeTo(560,(screen.availHeight-35));})();
I've noticed the same problem in Fx22 on a different computer. So apparently, even with javascript enabled, these functions don't work from the URL line.
Is there any way to resize a window, other than by manually dragging a corner?
Chosen solution
You can't run JavaScript code via the location bar anymore, so you need to use the command line of the Web Console instead.
- Firesizer: https://addons.mozilla.org/firefox/addon/firesizer/
- Custom Geometry: https://addons.mozilla.org/en-US/firefox/addon/custom-geometry/
- Bug 656433 - Disallow javascript: URLs to be run from the URL bar
All Replies (9)
hello, this seems nearly impossible now - for reference see: http://kb.mozillazine.org/Resizing_oversize_window#JavaScript_no_longer_allowed_to_resize_windows
philipp, I looked at the original bug report at: https://bugzilla.mozilla.org/show_bug.cgi?id=565541https://bugzilla.mozilla.org/show_bug.cgi?id=565541
I can see where a web-page might possibly need to be blocked, but not user defined bookmarklet operations. The difference is easy to detect -- it is the URL line, or it is embedded in the page. As you said, resize is nearly impossible now, so much so that it's really not possible for a novice user. I used to send constructed web-pages back to users who wanted to print the page, so I embedded javascript window resize logic so the user could simply print the page, and it would match an 8x11 sheet of paper. Now these people have to adjust their window manually. The only other method I can envision is to create a table with fixed-width dimensions so that table prints properly. I'm now sure that's possible.
The bug report doesn't really say much, but the aftermath of the "fix" has a huge impact of everyone. I can't, in good faith, mark your response as "solved the problem" because there doesn't appear to be any simple way to resize. The instructions given in the URL you supplied seem way beyond most people.
I don't understand your scenario of resizing the Firefox window to print it. Do you mean to capture a screen shot of it?
If it's okay to reload the page, you can have your bookmarklet relaunch it in a sized pop-up. For example:
javascript:void(window.open(window.location.href, '_blank', 'top=0,left=0,width=800,height=screen.availHeight,resizable,scrollbars,menubar'));
jsher, NO, not a screen shot, a cmd-P (print). Even with "style" as follows:
<style type="text/css" media="print"> @page onepage {size: 8.5in 11in; margin: 1cm} BODY {page: onepage; font-size: 9pt} TABLE {font-size: 9pt} </style>
The page doesn't print properly. And I believe javascript, as you suggest, doesn't work anymore within an html-page. My web server creates a form the recipient is supposed to print, and it doesn't print properly. I'm not doing the printing, the recipient is doing it, and they're NOT very computer literate.
DICKGUERTIN modificouno o
Such code still works in XUL pages (tabs) like about:config and about:addons and about:newtab in the Web Console (Firefox/Tools > Web Developer;Ctrl+Shift+K), but not in normal tabs.
Most pages can be printed on the user's current paper size with the user's preferred margins by using the default setting of "Shrink to Fit" in the Page Setup dialog. The size of the browser window should have no effect on the size of the page when printed.
The script I posted would be for use as a bookmarklet, instead of your current bookmarklet, not in a web page.
However... there are some style rules that Firefox handles easily on screen media but which cause problems when printing. These include overflow rules other than overflow:visible, some uses of position:absolute, using display:table for elements other than tables, various float scenarios, and others that aren't immediately coming to mind. As far as I know, these problems are independent of window size.
Chosen Solution
You can't run JavaScript code via the location bar anymore, so you need to use the command line of the Web Console instead.
- Firesizer: https://addons.mozilla.org/firefox/addon/firesizer/
- Custom Geometry: https://addons.mozilla.org/en-US/firefox/addon/custom-geometry/
- Bug 656433 - Disallow javascript: URLs to be run from the URL bar
Firesizer 1.7 did it for me! It is simple to use, and can be configured. It requires the "Add-On bar" at the bottom of the page, but that's OK. I've installed on Fx16 and Fx22, and it works on both. In my opinion, this should have been the ANSWER from the beginning.