This works in IE6, but not FF2 or Opera9

Z

Zilbandy

I've tried the following with IE6, FireFox2 and Opera9. Javascript is
enabled in all three browsers but this only works in IE. I'm very new
to Javascript and this first exercise is very frustrating. Here's the
code in question:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Tubac Woodworks, Inc. — Portfolio</TITLE>
<META http-equiv="Content-Type" Content="text/html; charset=utf-8">
<META http-equiv="refresh" content="2;url=./PageB/frameset.htm">
<script type="text/javascript" language="javascript">
function detect(){
if(screen.width<1024){
location.href('PageA/frameset.htm');
}else{
location.href('PageB/frameset.htm');
}
}
</script>
</HEAD>
<BODY onLoad="detect()">
</BODY>
</HTML>

The url to the page of concern is http://tubacwoodworks.com. If you
visit this page, no comments on using frames for layout, please. I'm
trying to address one problem at a time. :) CSS is just as new to me
as JS.
 
R

Randy Webb

Zilbandy said the following on 11/20/2006 12:47 AM:
I've tried the following with IE6, FireFox2 and Opera9. Javascript is
enabled in all three browsers but this only works in IE. I'm very new
to Javascript and this first exercise is very frustrating. Here's the
code in question:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Tubac Woodworks, Inc. — Portfolio</TITLE>
<META http-equiv="Content-Type" Content="text/html; charset=utf-8">
<META http-equiv="refresh" content="2;url=./PageB/frameset.htm">
<script type="text/javascript" language="javascript">

Drop the language attribute, it is deprecated.
function detect(){
if(screen.width<1024){
location.href('PageA/frameset.htm');

Check the JS Console and it will tell you "location.href is not a
function". You don't call it the way you did, you set it:

location.href="PageA/frameset.htm";
}else{
location.href('PageB/frameset.htm');

Same here.

The url to the page of concern is http://tubacwoodworks.com. If you
visit this page, no comments on using frames for layout, please. I'm
trying to address one problem at a time. :) CSS is just as new to me
as JS.

A better question to ask yourself is why does my resolution matter? What
is more important is the size of the browser window and you can find
code here:

<URL: http://jibbering.com/faq/#FAQ4_9>

<FAQENTRY>
4.9 needs to be renamed, it doesn't deal with the size of the window. It
should also have a note added specifying that you can't get the proper
dimensions until after the page has finished loading

Between the last code box and the links:

Note: The dimensions can not be determined accurately until after the
document has finished loading.

</FAQENTRY>
 
Z

Zilbandy

Check the JS Console and it will tell you "location.href is not a
function". You don't call it the way you did, you set it:

location.href="PageA/frameset.htm";


Same here.

<snip>

Thank you. That seems to have fixed it. :)

A better question to ask yourself is why does my resolution matter? What
is more important is the size of the browser window . . . .

I load smaller images for those using 800x600 screen resolution to
avoid horizontal scroll bars. Let's face it, if you are still using
800x600, you are probably running full screen, or you surely have a
fetish for horizontal scroll bars with the seemingly vast majority of
sites today needing 1024x768 run at full screen to avoid horizontal
scrolling. And, then there are the ones that even when using 1024x768
seem to be a few pixels too big anyway and still have scroll bars.
It's like the "designer" forgot about the window borders and the
vertical scroll bars when they built the page. :)
 
A

ASM

Zilbandy a écrit :
I've tried the following with IE6, FireFox2 and Opera9. Javascript is
enabled in all three browsers but this only works in IE.
<script type="text/javascript" language="javascript">
function detect(){
if(screen.width<1024){

it is a very bad idea :
my screen is >1024 width
but my borowser's window is by 850px width ...
location.href('PageA/frameset.htm');

location.href = 'PageA/frameset.htm';
 
A

ASM

Zilbandy a écrit :
I load smaller images for those using 800x600 screen resolution to
avoid horizontal scroll bars.

But my screen is 1152/870
Does that mean I use my browsers in full screen ? Not at all !
with the seemingly vast majority of
sites today needing 1024x768 run at full screen to avoid horizontal
scrolling.

It's why I visit them in 850 width
--> avoid right column with advertisements ;-)
And, then there are the ones that even when using 1024x768
seem to be a few pixels too big anyway and still have scroll bars.

You know you can code in proportional sizing ?
(all the page adapts its elements relatively to free space in width)
 
Z

Zilbandy

But my screen is 1152/870
Does that mean I use my browsers in full screen ? Not at all !


Then that means you should have no problems viewing my site with no
horizontal scrolling needed. :)
 
Z

Zilbandy

it is a very bad idea :
my screen is >1024 width
but my borowser's window is by 850px width ...

Then you would notice the note on the page to select the smaller page
if images appeared too big. Still, not a problem. I'd venture a guess
that your "typical" internet user is using either 800x600 or 1024x768
at full screen. By virtue of the fact that you are answering questions
in this group tells me you are not the "typical" user. To you, it's a
"very bad" idea; to me, it seems like a decent solution.
 
R

Randy Webb

Zilbandy said the following on 11/20/2006 12:45 PM:
Then you would notice the note on the page to select the smaller page
if images appeared too big. Still, not a problem. I'd venture a guess
that your "typical" internet user is using either 800x600 or 1024x768
at full screen.

I would beg to differ with that statement. The "typical" internet user
doesn't use full screen. The IT department where I work had a big
argument about two years ago about whether people surfed in max mode or
not (maximized or full scree - they are distinct). The solution? We put
a JS snippet in the homepage that logs the screen width and the browser
width to the server. Results? 99% did *not* surf maximized or full
screen. The average seems to be about 50-60% of desktop width. Stats are
flawed by the very nature of them but I don't think the "typical user"
surfs the web with the browser maximized.
 
Z

Zilbandy

Results? 99% did *not* surf maximized or full
screen. The average seems to be about 50-60% of desktop width.

I find that hard to believe, based on just visiting random web sites.
If that's the case, there's an awfully lot of people accepting the use
of horizontal scrolling. I am forced to use 800x600 if I want to be
able to read the text and the vast majority of pages are not
"friendly" at this resolution. I just can't imagine making the screen
more narrow yet. I guess the point is that you can't please everybody.
I got my Javascript question answered, and whether or whether not what
I'm doing with it is politically correct, I'm happy with it and my
friend at the company I'm doing it for is happy with it... for now. :)
 
A

ASM

Zilbandy a écrit :
I think most of Windows family users have their applications opened in
full screen (it's a default feature of Windows).
Probably at work and usually the surf run in back in a reduced window.
I find that hard to believe, based on just visiting random web sites.

It is not "because" it is usually wrong made you have to follow them.
If that's the case, there's an awfully lot of people accepting the use
of horizontal scrolling. I am forced to use 800x600 if I want to be
able to read the text and the vast majority of pages are not
"friendly" at this resolution.

No, and these ones aren't often visited (if known).
I'm doing with it is politically correct, I'm happy with it and my
friend at the company I'm doing it for is happy with it... for now. :)

Anyway what we mean is you have to detect available space of browser's
window and not size of screen if you want to be compatible with any use
of your visitors.

Il n'y a pas à sortir de là.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top