i created a simple popup window
using this script

function MyPopUp(c) {

which works

but is it possible to modify the size according to the browser with?

if (screen.width == 1024 size ""
if (screen.width == 1280 size ""


The width of the browser width is window.innerWidth , but don't test if it's 1024, etc, because even if the user's screen resolution is indeed 1024x768, the window can be resized and it will be something else. screen.width is the width of the screen, not the browser window, but same story here: don't let your sites functionality depend on a specific screen width.

Hi Twiss
im using it for the gallery section which has a screenshot and option to visit the site.
i set the popup to 1024 on width for 1280 and up screen width, but i wish to make it smaller if the browser is less than 1280 so it wont cover my site. can you help me with this script?

For usability, I would not test anything but just make the popup, say, the width of the screen minus 200 pixels:

function MyPopUp(c) {
  window.open(c, 'window', 'width='+(screen.width - 200)+',height=480,scrollbars=yes,status=yes');

Thanks twiss but i cant make it to work

What doesn't work? Make sure your pop-up blocker is disabled.

when i used the script, it maximize the width (popup) eg. 1920 width 480 height

i though the popup width will depend on browser window width.
like if i resize my browser to much smaller then the popup will adjust accordingly

Do you want the popup to resize after you've opened it if you resize the main window?

i just want it to detect the browser size
if the browser has more that 1280 width then the specific size will open if it has less than 1280 then it will open different size.
your first concept is great though (-200)

Okay, if you like the -200 thing, just change screen.width to window.innerWidth.

its working now! thanks twiss, thought the height doesnt change. is it possible to include the height?

if this is much gonna be complicated, its really alright
im happy with the inner width.
Thank a lot Twiss!

function MyPopUp(c) {
  window.open(c, 'window', 'width='+(window.innerWidth - 200)+',height='+(window.innerHeight - 200)+',scrollbars=yes,status=yes');

A big thanks twiss! its perfect!

No problem :)