Search Support

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.

Learn More

Javascript command not working from address bar

  • 7 replies
  • 167 have this problem
  • 26 views
  • Last reply by gfullam

more options

Up until Version 6.0.2 FF supports the following command via the address bar "javascript:window.resizeTo(1280,1024);". In version 7.0.1 and in the beta version 8 - this is no longer supported. I use this all day in my role as a project manager to test web pages in different screen resolutions and I've had to downgrade back to 6.0.2 just for this feature.

Has the support for this been withdrawn permanently or is there a way to enable it in v7 or v8?

Thanks.

Up until Version 6.0.2 FF supports the following command via the address bar "javascript:window.resizeTo(1280,1024);". In version 7.0.1 and in the beta version 8 - this is no longer supported. I use this all day in my role as a project manager to test web pages in different screen resolutions and I've had to downgrade back to 6.0.2 just for this feature. Has the support for this been withdrawn permanently or is there a way to enable it in v7 or v8? Thanks.

Chosen solution

Starting in Firefox 6 javascript in the url-bar runs with a null security principal for security reasons. This means it's almost disabled. You need a bookmarklet or an add-on for a workaround. See question 871828.
Bug 656433 - Disallow javascript: and data: URLs entered into the location bar from inheriting the principal of the currently-loaded page

Starting in Firefox 7 window moving and resizing is no longer allowed with a few exceptions. See question 880032.
Bug 565541 - Web sites shouldn't be allowed to resize main window

Read this answer in context 👍 4

All Replies (7)

more options

That kinds of kills JavaScript tutorials, and even how bookmarklets are something you could type into the location bar to run/test and bookmark.

javascript:alert("Hello World")

Ran into this on Sat or Sun and the first thing I checked was Tools > Options > Content > Javascript: Advanced and all A-OK. Didn't really sink in that it was Firefox 7.0.1 until you mentioned it. I just used the bookmark and figured I'd messed up something. I do have several resize bookmarks but that is how I test. It sort of kills the instructions in the MozillaZine KB article.

The answer is probably in here somewhere, would hate to think I'd have to code a dozen policy statements or one allow everything:

This is what i tried and failed with, it has to say who has access

//* 7.0.1 resize user_pref("capability.policy.policynames", "default"); user_pref("capability.policy.default.Window.alert", "allAccess"); user_pref("capability.policy.default.Window.confirm", "allAccess"); user_pref("capability.policy.default.Window.prompt", "allAccess"); user_pref("capability.policy.default.Window.innerWidth.set", "allAccess"); user_pref("capability.policy.default.Window.innerHeight.set", "allAccess"); user_pref("capability.policy.default.Window.outerWidth.set", "allAccess"); user_pref("capability.policy.default.Window.outerHeight.set", "allAccess"); user_pref("capability.policy.default.Window.sizeToContent", "allAccess"); user_pref("capability.policy.default.Window.resizeTo", "allAccess"); user_pref("capability.policy.default.Window.resizeBy", "allAccess");

// allow/Prevent web pages from moving browser windows

user_pref("capability.policy.default.Window.screenX.set", "allAccess"); user_pref("capability.policy.default.Window.screenY.set", "allAccess"); user_pref("capability.policy.default.Window.moveTo", "allAccess"); user_pref("capability.policy.default.Window.moveBy", "allAccess");

more options

Downgrading from 7.0.1 didn't prove easy either - I couldn't find anywhere to download 6.0.2 from the Mozilla website. I also tried upgrading to the Version 8 beta to see if the Javascript commands were working but sadly not.

Chrome has a decent resize extension here: https://chrome.google.com/webstore/detail/kkelicaakdanhinjdeammmilcgefonfh]]

I haven't managed to find one for FF and if there is one, not sure if it will work with v7+.

more options

Chosen Solution

Starting in Firefox 6 javascript in the url-bar runs with a null security principal for security reasons. This means it's almost disabled. You need a bookmarklet or an add-on for a workaround. See question 871828.
Bug 656433 - Disallow javascript: and data: URLs entered into the location bar from inheriting the principal of the currently-loaded page

Starting in Firefox 7 window moving and resizing is no longer allowed with a few exceptions. See question 880032.
Bug 565541 - Web sites shouldn't be allowed to resize main window

more options

Thanks knorretje amazing how much crap one puts up with when you think you have more control. Goodbye to 27 bookmarklets that really helped, goodbye to a couple of Mozillazine articles that helped many people. Was going to mark as solved (reluctantly, of course when solved does not mean fixed) and realized it not only wasn't my problem but I've never even posted a problem here. Thanks for the links.

Windows 7 has nice keyboard shortcuts specifically for left or right half of screen or maximize/normalize (restore). "Winkey+arrowkey" but they also make manually moving windows to edges of screen difficult without grabbing the edges. The keyworded bookmarks were a great help for viewing and checking out my web pages.


Summary of steps described in http://kb.mozillazine.org/Resizing_oversize_window

  1. use "Alt+Spacebar" in Windows to Maximize active window
  2. Change services.sync.prefs.sync.dom.disable_window_move_resize to false using about:config
  3. Create a bookmarklet (bookmark with JavaScript) having a location of
    javascript:self.resizeTo(1024,screen.availHeight);self.moveTo(screen.availWidth-1024,0);
    (reduce from 1024 if your screen width is less than 1024)
  4. about:config must be the active tab
  5. Invoke the bookmark directly from your bookmarks (with Firefox 7.0.1 you can no longer invoke a keyword shortcut from the location bar involving move/resize).

Modified by David McRitchie

more options

You can run JavaScript code in the Firefox > Web Developer > Scratchpad, but you can't resize the main window.
Only windows created via window.open() can be resized.

  • bug 565541 - Web sites shouldn't be allowed to resize main window (#c24)
more options

I've accepted a Solution but the problem isn't solved.

I don't understand what problem there is with allowing the main window to be resized. If some websites abuse this then users will stop using them! Having read the comments in the link knorretje posted, the discussion seems to have faded and those who relied on this functionality remain unappeased.

I'll be sticking with FF v6.0.2 for sometime and will switch to Chrome as my default browser as it has an easy to use resize extension.

more options

I'm shocked. This seems like something Microsoft would implement in Internet Explorer. Thanks for the about:config trick. That worked, but it's grossly unreasonable. Mo' zilla, Mo' problems.