Click to See Complete Forum and Search --> : Could I have some help please. Regarding Javacript.


RazorianFly
04-13-2007, 10:53 AM
Hello, i'm new here, I just sourced this link as I have a problem.
Here is the script (resolution redirection):

<HEAD>

<script type="text/javascript">
<!-- Begin

var thiswidth=screen.width;
var thisheight=screen.height;

// file to load if resolution is 640x480:
var if640x480 ="";

// file to load if resolution is 800x600:
var if800x600="";

// file to load if resolution is 1024x768:
var if1024x768="";

// file to load if resolution is 1152x864:
var if1152x864="";

// file to load if resolution is 1280x720:
var if1280x720="";

// file to load if resolution is greater than 1280x720:
var Redirect ="";

// Do not change anything below this line
// --------------------------------------
var width1 = 640; var height1 = 480;
var width2 = 800; var height2 = 600;
var width3 = 1024; var height3 = 768;
var width4 = 1152; var height4 = 864;
var width5 = 1280; var height5 = 720;

if (screen.width == width1 || screen.height == height1){
location=(if640x480);}
else if(screen.width == width2 || screen.height == height2){
location=(if800x600);}
else if(screen.width == width3 || screen.height == height3){
location=(if1024x768);}
else if(screen.width == width4 || screen.height == height4){
location=(if1152x864);}
else if(screen.width == width5 || screen.height == height5){
location=(if1280x720);}
else if(screen.width >= width5 || screen.height >= height5){
alert(msg);
}
//-->
</script>

I'm trying to encorporate a 5 second delay into this script. Does anyone have any idea what line of code needs to go in, and where?

Thanks for the help in advance,
R-Fly

TheBearMay
04-13-2007, 11:02 AM
This should be close:

<!-- Begin

var thiswidth=screen.width;
var thisheight=screen.height;

// file to load if resolution is 640x480:
var if640x480 ="";

// file to load if resolution is 800x600:
var if800x600="";

// file to load if resolution is 1024x768:
var if1024x768="";

// file to load if resolution is 1152x864:
var if1152x864="";

// file to load if resolution is 1280x720:
var if1280x720="";

// file to load if resolution is greater than 1280x720:
var Redirect ="";

// Do not change anything below this line
// --------------------------------------
var width1 = 640; var height1 = 480;
var width2 = 800; var height2 = 600;
var width3 = 1024; var height3 = 768;
var width4 = 1152; var height4 = 864;
var width5 = 1280; var height5 = 720;
setTimeout("redirect();",5000);
function redirect(){
if (screen.width == width1 || screen.height == height1){
location=(if640x480);}
else if(screen.width == width2 || screen.height == height2){
location=(if800x600);}
else if(screen.width == width3 || screen.height == height3){
location=(if1024x768);}
else if(screen.width == width4 || screen.height == height4){
location=(if1152x864);}
else if(screen.width == width5 || screen.height == height5){
location=(if1280x720);}
else if(screen.width >= width5 || screen.height >= height5){
alert(msg);
}}

Tweak4
04-13-2007, 01:13 PM
However, you can't assume that any particular user has their browser maximized. The screen resolution has virtually zero relevance to the size of the browser window. Therefore, you'll be much farther ahead ignoring the resolution entirely and getting the size of the users browser instead.