/    Sign up×
Community /Pin to ProfileBookmark

resize window

Hi!

Is there a script that resizes the current browser window to show 100% width and height of content in page? Right now I’m using the script below that allows me to set a specific pixel value for width and height, but because each browser/platform has different toolbars, the window size isn’t consistant across all browsers and my content gets cut off or shows extra space around it.. anybody know?

<script language=”JavaScript”>
<!–
// This will resize the window when it is opened or
// refresh/reload is clicked to a width and height of 500 x 500
// with is placed first, height is placed second
window.resizeTo(890,740)
// –>
</script>

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@zyghJul 18.2006 — u could try this... i might work... (not tested)

[code=html]
if (window.innerHeight) {
//netscape supported
height = window.innerHeight
}
else {
height = window.document.body.clientHeight
}

if (window.innerWidth) {
//for ie users...
width = window.innerWidth
}
else {
width = window.document.body.clientWidth
}
[/code]


then u can use the values of height and width...

i dunno i could be wrong...
Copy linkTweet thisAlerts:
@NulrickauthorJul 18.2006 — you mean I add this code into mine above, or replace it?
Copy linkTweet thisAlerts:
@NulrickauthorJul 18.2006 — doesn't seem to solve the problem.. browser window is different size in safrai, firefox than it is in I.E. I wrote it out like this:

<script language="JavaScript">

<!--

// This will resize the window when it is opened or

// refresh/reload is clicked to a width and height of 500 x 500

// with is placed first, height is placed second

window.resizeTo(890,750)

if (window.innerHeight) {

//netscape supported

height = window.innerHeight

}

else {

height = window.document.body.clientHeight

}

if (window.innerWidth) {

//for ie users...

width = window.innerWidth

}

else {

width = window.document.body.clientWidth

}

// -->

</script>
Copy linkTweet thisAlerts:
@zyghJul 18.2006 — opps i noticed an error in my code.. its fixed now... it was a note...
[code=html]
if (window.innerHeight) {
//netscape supported
height = window.innerHeight
}
else {
//for ie users
height = window.document.body.clientHeight
}

if (window.innerWidth) {
width = window.innerWidth
}
else {
width = window.document.body.clientWidth
}
[/code]


This will return the usable space in there window......

you mean I add this code into mine above, or replace it?[/QUOTE]
it will make it so u wouldn't have to resize there window at all and u can use the values (in the above example: height, width) to adjust ur elements accordingly...
Copy linkTweet thisAlerts:
@NulrickauthorJul 18.2006 — hmm.. sorry I'm not much of a scripter, so I've written it out as it appears below, however i'm still at my starting poitn.. the browser window size is different in I.E. than it is in Safari or Firefox:


<script language="JavaScript">

<!--

window.resizeTo(890,720)

if (window.innerHeight) {

//netscape supported

height = window.innerHeight

}

else {

//for ie users

height = window.document.body.clientHeight

}

if (window.innerWidth) {

width = window.innerWidth

}

else {

width = window.document.body.clientWidth

}

// -->

</script>
Copy linkTweet thisAlerts:
@zyghJul 18.2006 — hmm....
<script language="JavaScript">

<!--

window.resizeTo(890,720)

if (window.innerHeight) {

//netscape supported

height = window.innerHeight

}

else {

//for ie users

height = window.document.body.clientHeight

}

if (window.innerWidth) {

width = window.innerWidth

}

else {

width = window.document.body.clientWidth

}

// -->

</script>[/QUOTE]


that wasn't what i was going for... but if u do something like...
[code=html]
<script language="JavaScript">
<!--

if (window.innerHeight) {
//netscape supported
wHeight = window.innerHeight
}
else {
//for ie users
wHeight = window.document.body.clientHeight
}

if (window.innerWidth) {
wWidth = window.innerWidth
}
else {
wWidth = window.document.body.clientWidth
}

tableH = document.getElementById("table")
tableH.height = wHeight

// -->
</script>

~~later in the code~~

<table id="table">
~~more code~~
</table>[/code]


would create a varible table with a height of the window... hmmm maybe i'm not explaining it good.... i dunno
×

Success!

Help @Nulrick spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...