|
-
Apr 26th, 2002, 10:48 PM
#1
Thread Starter
Stuck in the 80s
Resolution Detection
Code:
if (screen.width<1024||screen.height<768) {
//do something
}
This works for IE, what's the equivalent in Netscape 6 and Navigator 4?
I have tables on my page, but if the resolution is too low, I need to display them on ontop of the other instead of side by side.
-
Apr 27th, 2002, 10:14 AM
#2
Fanatic Member
strange... screen.width should work. It was introduced in both Netscape and Internet Explorer 4
Code:
window.screen.width
Does it not work at all?
-
Apr 27th, 2002, 10:32 AM
#3
Thread Starter
Stuck in the 80s
No, it does not. Only in Internet Explorer.
-
Apr 27th, 2002, 02:05 PM
#4
Thread Starter
Stuck in the 80s
Oh, you may be correct.
Does 'document.write' work with Netscape? If it doesn't, then that's my problem.
-
Apr 27th, 2002, 02:15 PM
#5
PowerPoster
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
-
Apr 27th, 2002, 02:28 PM
#6
Thread Starter
Stuck in the 80s
Code:
<script>
var w = screen.width;
var h = screen.h;
if (w < 1024 || h < 768) {
document.write('poo');
}
</script>
Nothing shows up in my Netscape 6.2 window when the resolution is 800 x 600. What am I doing wrong? It works fine in IE.
-
Apr 27th, 2002, 02:31 PM
#7
Member
In Nutscrape, type "javacsript:" in the address bar to see details about script errors...you might be missing something.
-
Apr 27th, 2002, 02:38 PM
#8
Thread Starter
Stuck in the 80s
Yeah, it's given me a syntax error, but it doesn't say what line or anything.
-
Apr 27th, 2002, 02:40 PM
#9
Member
This is weird...
Shouldn't that be
Code:
var h = screen.height;
...
-
Apr 27th, 2002, 02:46 PM
#10
Thread Starter
Stuck in the 80s
Yeah, I just caught that too. And now I'm getting:
Error: redeclaration of const kIOServiceProgID
Source File: chrome://communicator/content/utilityOverlay.js
Line: 1
-
Apr 27th, 2002, 02:54 PM
#11
Thread Starter
Stuck in the 80s
I changed it to:
Code:
<script>
if (screen.width < 1024 || screen.height < 768) {
document.write("poo");
}
</script>
And it got rid of the errors, but it doesn't display "poo"
-
Apr 28th, 2002, 08:03 AM
#12
Fanatic Member
I take it you are loading this script upon loading the page?
try...
Code:
<script>
if (screen.width < 1024 || screen.height < 768) {
self.document.write("poo");
}
</script>
Not sure if its in the standard but it might be worth a try
-
Apr 28th, 2002, 09:18 AM
#13
Thread Starter
Stuck in the 80s
Now it'll write poo no matter what the resolution is.
-
Apr 28th, 2002, 09:36 AM
#14
Thread Starter
Stuck in the 80s
Code:
self.document.write("Width: " + screen.width + "<br>");
self.document.write("Height: " + screen.height);
In Netscape, will produce "Width: 800" and "Height: 600" when the resolution is set at 1024 x 768?? 
However in Internet Explorer, it will show the right dimensions.
(Testing in Netscape Navigator 4 and Netscape 6.2, btw)
-
Apr 29th, 2002, 04:19 AM
#15
Fanatic Member
Thats really weird...
have you tried 'window.screen.width'?
-
Apr 29th, 2002, 10:51 AM
#16
Black Cat
Mozilla RC1 - screen.height and screen.width seem to work correctly. Opera 6 as well.
Josh
Get these: Mozilla Opera OpenBSD
I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.
-
Apr 29th, 2002, 11:09 AM
#17
Thread Starter
Stuck in the 80s
Can anyone else test this code for me to make sure I'm not crazy?
Create file with this javascript in it:
Code:
self.document.write("Width: " + screen.width + "<br>");
self.document.write("Height: " + screen.height);
And with your resolution at 1024x768, see what it says. I tested with Netscape 6.2 and it gave me 800x600.
I think I tried window.screen, but I'll give it a shot again.
-
Apr 29th, 2002, 11:10 AM
#18
Thread Starter
Stuck in the 80s
Originally posted by The Hobo
I think I tried window.screen, but I'll give it a shot again.
Bah, I'll have to give it a shot later. I'm at school and they only have IE.
-
Apr 29th, 2002, 12:36 PM
#19
Black Cat
I think you might be crazy.
Anyway, I'm testing by typing "javascript:alert(screen.height);" in the address bar, and I forgot I have Netscape 6.1 installed, but it also gives my correct 1280x1024 screen resolution.
Josh
Get these: Mozilla Opera OpenBSD
I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.
-
Apr 29th, 2002, 12:54 PM
#20
Thread Starter
Stuck in the 80s
Originally posted by JoshT
I think you might be crazy.
Anyway, I'm testing by typing "javascript:alert(screen.height);" in the address bar, and I forgot I have Netscape 6.1 installed, but it also gives my correct 1280x1024 screen resolution.
***? Yeah, I think I am crazy...
I did the "javascript:alert(screen.height);" thing you did and it gave the correct dimensions. Let me run the code again one more time...
-
Apr 29th, 2002, 01:03 PM
#21
Thread Starter
Stuck in the 80s
Sigh, f'in, sigh.
I figured it out...
My original code:
Code:
if (screen.width < 1024 || screen.height < 768) {
self.document.write("poo");
}
The Code I should have had:
Code:
if (screen.width =< 1024 || screen.height =< 768) {
self.document.write("poo");
}
Now that I wasted everyone's bloody time, thanks for all the help!
-
Apr 29th, 2002, 01:14 PM
#22
Thread Starter
Stuck in the 80s
Another thing that was messing it up: I was changing the resolution, then hitting refresh in Netscape. The variables don't reset though, so it was still saying '1024x768' when it was 800x600. So I had to close the browser then reopen it.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|