0

Hello!
i created a simple popup window
using this script

function MyPopUp(c) {
window.open(c,
'window',
'width=480,height=480,scrollbars=yes,status=yes');
}

which works

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

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

Thanks!

2
Contributors
13
Replies
14
Views
6 Years
Discussion Span
Last Post by twiss
0

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.

0

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?

0

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');
}
0

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

0

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

0

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)

0

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!

0
function MyPopUp(c) {
  window.open(c, 'window', 'width='+(window.innerWidth - 200)+',height='+(window.innerHeight - 200)+',scrollbars=yes,status=yes');
}
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.