/    Sign up×
Community /Pin to ProfileBookmark

Table resize (layout question)

Hi !

I didn’t see a code similar to this one anywhere on the web so here i am (again) asking for a little help !

I want my tables to resize accordingly to the browser’s resizing but with a maximum !

For example, my page is best viewed under 1024*768.
If the user uses a 1024*
768 resolution and downsize his browser, all my tables will resize (since they are in %)

But if the user uses 1600*1200, it looks like shit so i want to set my tables so they stop resizing once they are, say, 1024 pixels wide and then starts to center themselves (horizontally and vertically – without resizing ! (just as if the width of the table were set to pixels but were nested within another table set with a width and height of 100%).
If that same user decides to downsize his browser, the tables won’t resize until the script determines that the browser he is resizing is inferior to 1024*
768, then the script makes the tables resize.
On the other hand, if the user try to upsize again, it will resize the tables until they are as larged as viewed under 1024*768 resolution. Then the tables will begin to be centered horizontally and vertically (as i was saying).

I think you guys can understand that i can’t use standard width & height tags. If i use it in pixels, the tables won’t resize and if i use %, they will resize indefinately and
won’t detect when to resize and when NOT to resize !!!

I’ve written a script for that for my website -it is my second and last attempt (up to this day) at writing javascript code, so don’t you laugh at me 😛
I nested my page’s content between this :

<script language=”JavaScript”>
if (document.all)
w=document.body.clientWidth;
else if (window.innerWidth)
w=window.innerWidth;
if (w >= 1024) {
tw = (1024/w)*100;
document.write(‘<TABLE align=”center” width=”‘+tw+’%” height=100% border=0 cellpadding=”0″ cellspacing=”0″ style=”border-collapse: collapse” bordercolor=”#111111″><TR><TD align=”center” valign=”middle”>’);
}
</script>

and this :

<script language=”JavaScript”>
document.write(‘</TD></TR></TABLE>’)
</script>

I also had to add this :

<script language=”JavaScript”>
function refresh() {
window.location.reload();
}
function refreshPage() {
setTimeout(“refresh()”,1000)
}
</script>

because if i remember right, NN reloads the page so it made the page content flickering while resizing, so i added a little timer so it flickers…less !!! I called the function with the body onresize=”refreshPage();”

I have put a demo up at :
[URL=http://pages.infinit.net/rouxjean/test2.htm]http://pages.infinit.net/rouxjean/test2.htm[/URL]

Now, put your screen resolution to 1280 or 1600. Resize the browser under IE and you’ll see what i mean. There is another bug as you’ll see that once the browser is more than 1024 the table centers itself vertically ! (i want it to be centered vertically all the time !)

I’m sure you’ll find a better way to go around this !!! I hate the fact that Netscape reload the damn page everytime !

Many thanks !

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@Khalid_AliJun 03.2003 — [i]Originally posted by rouxjean [/i]

[B]Hi !



..........I hate the fact that Netscape reload the damn page everytime !



[/B]
[/QUOTE]


That is because you are reloading the page every 1 minute..Its really a nice code....lol

function refreshPage() {

setTimeout("refresh()",1000)

}
Copy linkTweet thisAlerts:
@MotaboboauthorJun 03.2003 — I know i'm stupid but not that much lol :rolleyes:

I HAD TO reload the page because the table didn't resize in Netscape. In IE, the tables are resized along with the browser resizing, but not Netscape. I was wondering if there was a way to avoid that refresh function !

I was also asking if there was a better way to do this !
Copy linkTweet thisAlerts:
@MotaboboauthorJun 03.2003 — I wonder why nobody has thought of that before. I mean 80% of the sites using a "liquid" design looks like shit when they are viewed under 1280*1024 resolution when they have been designed for 1024*768 !!!

It is such a bad idea ???
×

Success!

Help @Motabobo 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 5.19,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...