Mourning the loss of our friend, WhitPhil.
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
 
Web Design & Development
Tag Cloud
access audio blue screen boot bsod connection crash dell desktop driver dvd email error excel excel 2003 firefox hard drive hardware hdmi hijackthis internet keyboard laptop malware monitor motherboard network networking outlook problem ram recovery router screen slow sound spyware tdlwsp.dll trojan upgrade vba video virus vista vundo windows windows 7 windows vista windows xp wireless
Search
Search for:
Tech Support Guy Forums > Internet & Networking > Web Design & Development >
Javascript help

Tip: Click here to scan for System Errors and Optimize PC performance
[ Sponsored Link ]

Closed Thread
 
Thread Tools
Devonance's Avatar
Computer Specs
Junior Member with 12 posts.
 
Join Date: Aug 2008
Experience: Intermediate
23-Sep-2008, 01:39 AM #1
Question Javascript help
I have this code right here:


<SCRIPT language="JavaScript">
<!--
if ((screen.width>=1024) && (screen.height>=768))
{
window.location="http://kevin61292.007si...
}
if ((screen.width>=1440) && (screen.height>=900))
{
window.location="http://kevin61292.007si...
}
if ((screen.width>=1360) && (screen.height>=768))
{
window.location="http://kevin61292.007si...
}
if ((screen.width>=1280) && (screen.height>=800))
{
window.location="http://kevin61292.007si...
}
if ((screen.width>=1280) && (screen.height>=768))
{
window.location="http://kevin61292.007si...
}
if ((screen.width>=1280) && (screen.height>=720))
{
window.location="http://kevin61292.007si...
}
if ((screen.width>=1152) && (screen.height>=864))
{
window.location="http://kevin61292.007si...
}
if ((screen.width>=800) && (screen.height>=600))
{
window.location="http://kevin61292.007si...
}

//-->
</SCRIPT>

and it works some of them time, what it does is it puts you to a different page according to your resolution on your computer. But, i have a 1440 by 900 resolution, and i put it down to 800 by 600, and it didn't go to the desired webpage for that resolution... did i type it in wrong? or does this code only work for 2 types of resolutions?

BTW, i meant to put the ... at the end of the site URL's, because i dont want people going there yet, lol.

thanks in advance!
MMJ's Avatar
MMJ MMJ is offline
Distinguished Member with 3,519 posts.
 
Join Date: Oct 2006
23-Sep-2008, 03:12 AM #2
What does the final url look like?

Code:
http://kevin61292.007xxxx.com/*WIDTH*x*HEIGHT*
?
Devonance's Avatar
Computer Specs
Junior Member with 12 posts.
 
Join Date: Aug 2008
Experience: Intermediate
23-Sep-2008, 10:34 AM #3
what do you mean? the URL doesnt have the *WIDTH*x*HEIGHT* in it


anyway, someone on yahoo answers gave me this:

Code:
<script type="text/javascript">
var w = screen.width;
var h = screen.height;

// first satisfied if/else-if will abort the remaining test, so 
// start with the largest width/height combination and 
// work down to the smallest - note that all after the first 
// are else-if, and the last is else
if ((w >= 1440) && (h >= 900)) {
loc = "http://kevin61292.007sites.com/biblebookcat-Highres1440by900.html
}
else if ((w >= 1360) && (h >= 768)) {
loc = "http://kevin61292.007sites.com/temp1.html
}
else if ((w >= 1280) && (h >= 800)) {
loc = "http://kevin61292.007sites.com/temp2.html
}
else if ((w >= 1280) && (h >= 768)) {
loc = "http://kevin61292.007sites.com/temp3.html
}
else if ((w >= 1280) && (h >= 720)) {
loc = "http://kevin61292.007sites.com/temp4.html
}
else if ((w >= 1152) && (h >= 864)) {
loc = "http://kevin61292.007sites.com/temp5.html
}
else if ((w >= 1024) && (h >= 768)) {
loc = "http://kevin61292.007sites.com/temp6.html
}
// default 
// replaces if ((w >= 800) && (h >= 600)) but actually 
// means ((w < 1024) && (h < 768)) as written
else {
loc = "http://kevin61292.007sites.com/test2.html
}

window.location = loc;
</script>

<SCRIPT LANGUAGE="JavaScript"> 
<!--
but it still doesnt work... all i want to is if someone comes to my website with 800x600 resolution, they wont have to scroll sideways, and if someone has 1440x900 (like me) they dont see the background image in the top left hand corner. i read online about this and they said to make a separate webpage for different resolutions. it that the only way?

i dont know php and very little Javascript, so is there a way to make the website look nice in a different resolution in HTML?
MMJ's Avatar
MMJ MMJ is offline
Distinguished Member with 3,519 posts.
 
Join Date: Oct 2006
23-Sep-2008, 12:24 PM #4
Yes, if you do it properly with CSS you can make it so that the layout is fluid.

I suggest that you make a new thread asking how to create fluid css layout where the background image stays centered.
Devonance's Avatar
Computer Specs
Junior Member with 12 posts.
 
Join Date: Aug 2008
Experience: Intermediate
23-Sep-2008, 04:48 PM #5
Thanks! i will make a new one
Closed Thread Bookmark and Share

Tags
html, javascript, resize, resolution

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Smart Search

Find your solution!



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.

Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -5. The time now is 03:19 AM.
Copyright © 1996 - 2009 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.
Powered by Cermak Technologies, Inc.