Click to See Complete Forum and Search --> : 800x600 compatability issue....


ColdSteel
08-20-2003, 01:19 PM
Well, I'm new to this forum...but here it goes....I am having some problamatic Javascript code. I am trying to code a site that loads different sized pictures according to the resolution of the viewer's screen (so that every user gets the best experience), but the way that I have it coded does not work in 800x600...it actually displays both sets of pictures, yet works fine in 1024x768....Below is the code that I am using:

<SCRIPT LANGUAGE="JavaScript">
var ScrnSize = "UnCommon"

if (navigator.appVersion.indexOf("4.") != -1 &&
navigator.appName.indexOf("Explorer") != -1) {
ScrnSize = screen.width + "x" + screen.height;
}
if (navigator.appVersion.indexOf("4.") != -1 &&
navigator.appName.indexOf("Netscape") != -1) {
ScrnSize = screen.width + "x" + (screen.height + 19);

}
switch(ScrnSize) {
case "800x600": document.write('<img src="Banner_Left(8-6).gif" width="616" height="68" hspace="0" vspace="0" border="0" align="left" usemap="#map800600"> <map name="map800600" id="map800600"><area shape="rect" coords="323,31,389,56" href="#" alt="About Us"><area shape="rect" coords="387,31,461,56" href="#" alt="Contact Info"><area shape="rect" coords="460,31,545,56" href="#" alt="Go to the Selling From"></map><img src="Banner_Right(8-6).gif" width="95" height="182" hspace="0" vspace="0" border="0" usemap="#Map8006002"> <map name="Map8006002" id="Map8006002"><area shape="poly" coords="84,5,58,5,11,62,11,173,87,172" href="#" alt="Go to the Selling Form"></map>');
case "1024x768": document.write('<img src="Banner_Right.gif" width="127" height="243"hspace="0" vspace="0" border="0" align="right" usemap="#Map1024768"> <map name="Map1024768"> <area shape="poly" coords="78,8,16,82,15,227,115,228,114,8" href="#" alt="Go to the Selling Fom"></map> <img src="Banner_Left.gif" width="821" height="90" hspace="0" vspace="0" border="0" align="right" usemap="#Map"> <map name="Map"> <area shape="rect" coords="431,42,515,73" href="#" alt="Info about S &amp; J Properties"><area shape="rect" coords="516,42,615,73" href="#" alt="Contact info"><area shape="rect" coords="614,42,728,73" href="#" alt="Go to Selling Form"> <area shape="rect" coords="189,54,272,79" href="Mailto:stesteel@iquest.net" alt="Send us an e-mail"><area shape="rect" coords="189,54,272,79" href="Mailto:stesteel@iquest.net" alt="Send us an e-mail"></map>');

}
// End -->
</script>

I know that the links aren't in working order yet...but I'm just trying to get the compatability issue down....It's also kinda confusing with the image map and all....but any help would be greatly appreciated!!!:confused:

diamonds
08-20-2003, 03:32 PM
People In these froums tend to stay away from people who use lots of fancy words and people who speek hacker ("l-l o VV @rE y0u d0lng?"), as well as people who post big, long, questions.

Anyway, just use a redirection script.
javascript.internet.com has plenty of scripts like this.

Exuro
08-21-2003, 12:16 AM
Well, you should have a break; after each of your cases. Other than that, it looks like it should work fine... Is there some problem you didn't mention?

ColdSteel
08-21-2003, 07:17 AM
First of all....I realize that the way that I put my question is out of place a bit...the way that I should have asked is whether someone has had this problem and how they have fixed it....I don't really want to use a redirection script....but would like to just change which images appear according to the resolution....one set of images is smaller for 800x600, and one set is larger for 1024x768....if you follow me...if anyone is wondering why I seem to be very new to Javascript, it's 'cause I'm only 14, and am still in the process of learning it...by the way, Exuro, when you say BREAK, you don't mean HTML break tag <BR> do you? If you don't then what is a Break? Sorry...Newbie to javascript....if you can, please put up with me! thanks....I really appreciate any of the help....

Exuro
08-21-2003, 04:55 PM
Well, the way I usually do multi-resolution pages is I give each image a name, and then depending on the screen size I change the src for it using JavaScript. But, I don't think that would work so well for you since you're using image maps as well...

No, I did not mean <br> when I said break. This is what I was talking about:

switch(ScrnSize) {
case "800x600":
document.write("stuff");
break;
case "1024x768":
document.write("bigger stuff");
break;
}

ColdSteel
08-22-2003, 11:59 AM
Hey, Exuro....
Thanks for taking time out for a person like me....The only thing wrong with the script was the breaks....I'm still learning in Javascript right now...so thanks for putting up with a newbie like me.....