Javascript Problem

He has: 1,380 posts

Joined: Feb 2002

Hey...I am having two JS issues...neither of them will run. I have tried everything...so could you help me out?

I have this file:

function small() {
window.location="http://www.intuitiontech.com/msc/smindex.html";
}

function norm() {
window.location="http://www.intuitiontech.com/msc/normindex.html";
}

if ((screen.width=640) && (screen.height=480)) {
setTimeOut('small()', 5000);

}
else {
if ((screen.width>=1024) && (screen.height>=768)) {
setTimeOut('norm()', 5000);
};
}
'

which is referenced to in the following manner (in ):<script type="text/javascript" src="http://www.intuitiontech.com/msc/resolution.js"></script>

It won't run. I tried sending alert boxes and everything...I tried without timelimits...nothing works.

It can be seen at http://www.intuitiontech.com/msc/index.html

Thanks.

They have: 218 posts

Joined: Apr 2001

>setTimeOut();

Have you tried setTimeout() ?

TM

He has: 1,380 posts

Joined: Feb 2002

I first tried this script without even using the timeout...just straight redirect

They have: 5,633 posts

Joined: Jan 1970

I perfer open() over window.location but thats too simple to stress over it

They have: 218 posts

Joined: Apr 2001

A couple of things with your script...there are no settings for 800x600.
For clarity, you could probably reduce the code to one function:

function relocate()
{
             var sW = screen.width;
             var sH = screen.height;

   if (sW > 800)
     {
   var loc ="http://www.intuitiontech.com/msc/normindex.html";
     }
   else
       {
   var loc ="http://www.intuitiontech.com/msc/smindex.html";
       }

window.location = loc;

}
'

TM

He has: 1,380 posts

Joined: Feb 2002

that's all well and good, but two things:
#1- I'm not done with the script...there will be multiple screen resolution possibilites
#2- DOES ANYBODY KNOW WHY THIS DOESN'T WORK?

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

I don't see why you're setting functions.

Put the script in the and put the window.location lines in the actual conditions and it works fine.

They have: 5,633 posts

Joined: Jan 1970

I dont see anything wrong with it. Your computer is prouably just [word deleted].

They have: 218 posts

Joined: Apr 2001

>Have you tried setTimeout() ?

I tested your script and it works if you switch setTimeOut() to setTimeout().

TM

He has: 1,380 posts

Joined: Feb 2002

I was setting functions to make it easier to follow...

Thanks.

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

In this case the screen resize width/height test IS the function. The whole thing is the function. Smiling

He has: 1,380 posts

Joined: Feb 2002

Oh, ok.

Thanks.

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.