X
Tap here to go to the mobile version of the site.
Your Firefox is out of date and may contain a security risk! Upgrade Firefox

Support Forum

Javascript command not working from address bar

Posted

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

Additional System Details

This happened

Every time Firefox opened

This started when...

Upgrading to v7.0.1

Installed Plug-ins

  • ActiveTouch General Plugin Container Version 105
  • Office Plugin for Netscape Navigator
  • np-mswmp
  • npdivxplayerplugin
  • 6.0.12.448
  • RealPlayer(tm) LiveConnect-Enabled Plug-In
  • RealJukebox Netscape Plugin
  • NPRuntime Script Plug-in Library for Java(TM) Deploy
  • Adobe PDF Plug-In For Firefox and Netscape 10.1.1
  • Google Update
  • Shockwave Flash 11.0 r1
  • Adobe Shockwave for Director Netscape plug-in, version 11.5
  • iTunes Detector Plug-in
  • DivX Web Player version 2.1.1.94
  • DivX VOD Helper Plug-in
  • Picasa plugin
  • Next Generation Java Plug-in 1.6.0_26 for Mozilla browsers
  • 4.0.60310.0
  • NPWLPG
  • Windows Presentation Foundation (WPF) plug-in for Mozilla browsers
  • Motive Plugin for Mozilla Browsers
  • BlackBerry WebSL Browser Plug-In
  • The QuickTime Plugin allows you to view a wide variety of multimedia content in Web pages. For more information, visit the QuickTime Web site.

Application

  • User Agent: Mozilla/5.0 (Windows NT 6.0; WOW64; rv:6.0.2) Gecko/20100101 Firefox/6.0.2

More Information

As described above

David McRitchie 321 solutions 3089 answers

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");

Question owner

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+.

knorretje 161 solutions 582 answers

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

David McRitchie 321 solutions 3089 answers

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

cor-el
  • Top 10 Contributor
  • Moderator
10739 solutions 96650 answers

Helpful Reply

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)

Question owner

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.

gfullam 0 solutions 1 answers

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.