开发者

Change height of popup window

When I click on my extension icon a popup windows appears, but the problem I'm facing is that the popup windows height is too large so it gets below my taskbar. Is there anyway to set the height of the popup window?

I have tried with declaring height and width in a css file by the body tag. But only the width of the window changes. I have开发者_如何学编程 also tried with making an iframe, but the popup window only gets blank.


Add the following at the beginning of your popup page to replace the <html>:

<!DOCTYPE html>

Good luck!


You can set height and width of your popup window by using window.resizeTo(preferedWidth, preferedHeight) function. If you want to set this inside a popup window not from parent window than self.resizeTo(preferedWidth, preferedHeight); will do the job for you.

Better suggestion is to keep your content inside a div for example div with id 'content' so you can use this for popup window.

<head>
<script type="text/javascript">
function resizeMe()
{
    height = document.getElementById("content").offsetHeight;
    width  = document.getElementById("content").offsetWidth;
    self.resizeTo(width+20, height+100);
}
</script>
</head>

<body onload="resizeMe();">

This should be enough to solve your problem.


Try:

<style type="text/css">
    body {
       max-height: 300px;
    }
</style>

or just,

<style type="text/css">
    body {
       height: 300px;
    }
</style>

In the <head> tag of your popup.html.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜