shewok shewok - 5 months ago 17
HTML Question

Dynamic Height in JavaScript Popup Window

I'm trying to create a popup window that would have a fixed width but a dynamic height based on the user's screen size. Is this even possible? I've scoured this site and others to no avail.

I read the question below but I don't need it sized based on content.

Dynamic height for popups depending on content, is it possible?

I use the popup window for training. The window is auto-sized and positioned on one side of the screen and contains directions on how to use an application that takes up the remaining bit of the screen. The issue is, we have different sized monitors with different screen resolutions. Fortunately we only have to worry about IE11.

Here's a giant disclaimer; I don't know anything about JavaScript except that it exists and can possibly do what I need. I do, however, know HTML & CSS. So here's what I've got going on so far and I'm sure it's far from the proper way to do this:

<a href="link.html" onclick="javascript:void'link.html','1429893142534','width=290,height=675,toolbar=0,menubar=0,location=0,status=0,scrollbars=1,resizable=0,left=0,top=0');return false;">Link</a>

I tried omitting the height completely but that didn't work. The height that's there is based on the smallest screen the user might be working on, but looks pretty silly with a larger screen & resolution. Maybe something besides JavaScript would work better?

Thanks in advance for any responses!


You can do something like this:

<!DOCTYPE html>
<html xmlns="">
<a href="" onclick="openLink();">Link</a>
    function openLink()
    {'link.html','1429893142534','width=' + (parseInt(window.innerWidth) * 0.3) + ',height=' + (parseInt(window.innerHeight) * .3) + ',toolbar=0,menubar=0,location=0,status=0,scrollbars=1,resizable=0,left=0,top=0');
        return false;