Javascript help

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Devonance

Thread Starter
Joined
Aug 22, 2008
Messages
12
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

Guest
Joined
Oct 15, 2006
Messages
3,625
What does the final url look like?

Code:
http://kevin61292.007xxxx.com/*WIDTH*x*HEIGHT*
?
 

Devonance

Thread Starter
Joined
Aug 22, 2008
Messages
12
what do you mean? the URL doesnt have the *WIDTH*x*HEIGHT* in it :confused:


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

Guest
Joined
Oct 15, 2006
Messages
3,625
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.
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Top