Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

Resize a popup window in JavaScript?

I have a window that opens a popup and displays an .aspx file in the popup. Clicking on various links (from an image map) generate different .aspx files in the popup.

I know how large the popup is supposed to be, but I can't make the thing resize when I click on a different link. The first one opens to the correct size, but when I click on subsequent links, the text in the popup changes, but it doesn't resize. I've tried running a function that should resize in the body statements of the various files loaded in the popup, but that doesn't work.

Here are samples. I can send the entire thing to anyone who IM's me.

Sample:

From the main page:

<script language="JavaScript" type="text/javascript">

<!--

function openWindow(url, name, hhh) {

self.name = "main";

popupWin = window.open(url, name, "width=350,height=" + hhh + ",left=125,top=125");

popupWin.focus()

}

// -->

</script>

<area title="Alaska" shape="poly" coords="5,354,24,286,70,263,105,278,142,356,139,366,121,365,7,358"

href="javascript:openWindow('states/stateAK.aspx',%20'statepop','400');"

alt="Alaska">

</area>

<area title="Connecticut" shape="poly" coords="513,116,529,113,530,121,513,130"

href="javascript:openWindow('states/stateCT.aspx',%20'statepop','225');"

alt="Connecticut">

</area>

From stateCT.aspx (one of the files that displays in the popup)

<html>

<head>

<script language="JavaScript" type="text/javascript">

<!--

function FitText() {

self.resizeto = (350, 400);

}

// -->

</script>

<link rel="stylesheet" type="text/css" href="/css/state.css" />

</head>

<body onload='FitText();'>

1 Answer

Relevance
  • 1 decade ago
    Favorite Answer

    var x = 0;

    function openWindow(url, name, hhh) {

    if (x == 0) {

    self.name = "main";

    popupWin = window.open(url, name, "width=350,height=" + hhh + ",left=125,top=125");

    popupWin.focus()

    x = 1;

    } else {

    popupWin.close();

    popupWin = window.open(url, name, "width=350,height=" + hhh + ",left=125,top=125");

    }

    }

Still have questions? Get your answers by asking now.