We're calling on all EU-based Mozillians with iOS or iPadOS devices to help us monitor Apple’s new browser choice screens. Join the effort to hold Big Tech to account!

当サイトはユーザー体験を改善するためのメンテナンスを実施中に機能が制限される予定です。記事を読んでもあなたの問題が解決せず質問をしたい場合は、Twitter の @FirefoxSupport、Reddit の /r/firefox で、サポートコミュニティが皆さんを助けようと待機しています。

Mozilla サポートの検索

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

詳しく学ぶ

このスレッドはアーカイブに保管されました。 必要であれば新たに質問してください。

When did javascript to Resize windows stopped working?

  • 9 件の返信
  • 3 人がこの問題に困っています
  • 1 回表示
  • 最後の返信者: DICKGUERTIN

more options

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?

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?

選ばれた解決策

You can't run JavaScript code via the location bar anymore, so you need to use the command line of the Web Console instead.


  • Bug 656433 - Disallow javascript: URLs to be run from the URL bar
この回答をすべて読む 👍 2

すべての返信 (9)

more options
more options

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.

more options

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'));
more options

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 により に変更されました

more options

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.

more options

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.

more options

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.

more options

選ばれた解決策

You can't run JavaScript code via the location bar anymore, so you need to use the command line of the Web Console instead.


  • Bug 656433 - Disallow javascript: URLs to be run from the URL bar
more options

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.