6

In IE you can set the browser width to be 1024x768, for example, to test your site. How can you do this in Chrome? I can't find an equivalent setting anywhere? I'm using 'Tools -> Developer tools'.

I can't do the fallback trick of running

javascript:window.resizeTo(1024,768)

in the location bar, because Chrome tries to search for it!

1 Answer 1

8

You must type (not copy-paste) the entire Javascript (including "javascript:") into the address bar to execute Javascript - Chrome will strip the "javascript:" protocol specification and treat your Javascript as a search if your last action in the address bar is copy-pasting.

A more convenient way to execute arbitrary Javascript in Chrome would be to open the Javascript Console (Ctrl+Shift+J), however, the resizeTo() function is not supported for tabs so you'll need to enter something creative in the console to make this work:

var myTestWindow = window.open(window.location); myTestWindow.resizeTo(1024,768);

(subsequent changes to the pop-up window's size can be made by calling myTestWindow.resizeTo(x,y))

4
  • +1 That JS console way works, thanks. It's a bit inconvenient, but in the absense of anything better it's fine Dec 9, 2011 at 1:59
  • @Ralph I'd advise against doing this, it incredibly annoying for users to have their browser resized. Dec 9, 2011 at 10:13
  • @DisgruntledGoat - "...to test your site..."
    – danlefree
    Dec 9, 2011 at 17:10
  • Oh, my bad. To be honest it's probably better to resize by hand. I'd wager that no web browser window is ever sized at 1024x768, with task bars and toolbars and such. Dec 9, 2011 at 22:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.