Ron
Ron

Reputation: 6713

Popup windows sizes

I want to create a popup that will have a defined size like the BBC did. As you can see, when you click "Listen Live", they open a popup player, but I didn't understand how they did that.

Any chance for explanation?

Sorry, newbie in JavaScript

Upvotes: 0

Views: 100

Answers (1)

James Johnson
James Johnson

Reputation: 46047

Try using this function:

    openChildWindowWithDimensions = function(url, width, height, showMenu, canResize, showScrollbars) {
        var childWindow = window.open(url, "", "\"width=" + width + ",height=" + height + ",menubar=" + (showMenu ? "1" : "0") + ",scrollbars=" + (showScrollbars ? "1" : "0") + ",resizable=" + (canResize ? "1" : "0") + "\"");
        if (childWindow){
            childWindow.resizeTo(width, height);
        }
    }

I added the logic to resize the window because of a bug in IE9. Depending on what browser you're using, you may not need that bit.

Upvotes: 2

Related Questions