...

View Full Version : Javascript don't work on one computer but works on two other ones!



Cybershaolin
11-01-2004, 03:59 PM
I have a strange problem. I don't know if it's related to a change that I made to my equipment lately but here I go. It's kind of long but I want to give you all the details. (English is not my first language then please, be patient with me) :)

I have a javascript integrated in a php page. In the code, the script tells the browser to show a banner depending of the screen resolution.

It used to work before I change my videocard! After the card change, the banner did not show and I could not see the script when selecting View source. The weird thing is that it does that using three different browsers, IE 6.0, Opera 7.54 and Firefox 1.0. But if I use two other computers, the banner shows and the Javascript code is in the View Source.

Then, a few days ago, after rebooting a couple of times, it started to work again. After everything was working fine, I have decided to finally upgrade to SP2 for WinXP and also upgrade my video drivers to the latest working ones.

The problem has re-appeared!!! Again, I cannot see my banner caleld by the javascript routine anymore and it's not in the view source either. But, it still works with my two other computers. I tried clearing Temp files, cache, etc and rebooted many many times, nothing fixed it.

I dont know what is going on. It seems that I tried everything to correct the situation but nothing worked.

Here is the Javascript code:

<script language="JavaScript">
<!--
ecran = screen.width;
image1="Banner+(screen.width).swf"
{
switch(screen.width)
{

case 1600:
document.write ('<center><object '
+'codebase=" http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,79,0" '
+'id="Banner" align="center"'
+'WIDTH=1231 HEIGHT=67> <PARAM NAME=movie VALUE="Banner.swf'+document.location.search+'">'
+'<PARAM NAME=quality VALUE=high>'
+'<param name="scale" value="scale">'
+'<EMBED src="http://www.mysite.com/forum/style_images/1/Banner.swf' +document.location.search+'" '
+'quality=high scale="scale" WIDTH=1231 HEIGHT=67 '
+'TYPE="application/x-shockwave-flash"></EMBED></OBJECT></center>')
break;

case 1280:
document.write ('<center><object '
+'codebase=" http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,79,0" '
+'id="Banner" align="center"'
+'WIDTH="1231" HEIGHT="67"> <PARAM NAME=movie VALUE="Banner.swf'+document.location.search+'">'
+'<PARAM NAME=quality VALUE=high>'
+'<param name="scale" value="scale">'
+'<EMBED src="http://www.mysite.com/forum/style_images/1/Banner.swf' +document.location.search+'" '
+'quality=high scale="scale" WIDTH=1231 HEIGHT=67 '
+'TYPE="application/x-shockwave-flash"></EMBED></OBJECT></center>')
break;

case 1024:
document.write ('<center><object '
+'codebase=" http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,65,0" '
+'id="Banner" align="center"'
+'WIDTH=986 HEIGHT=65> <PARAM NAME=movie VALUE="Banner.swf'+document.location.search+'">'
+'<PARAM NAME=quality VALUE=high>'
+'<param name="scale" value="scale">'
+'<EMBED src="http://www.mysite.com/forum/style_images/1/Banner.swf' +document.location.search+'" '
+'quality=high scale="scale" WIDTH=986 HEIGHT=65 '
+'TYPE="application/x-shockwave-flash"></EMBED></OBJECT></center>')
break;

case 800:
document.write ('<center><object '
+'codebase=" http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,65,0" '
+'id="Banner" align="center"'
+'WIDTH=755 HEIGHT=50> <PARAM NAME=movie VALUE="Banner.swf'+document.location.search+'">'
+'<PARAM NAME=quality VALUE=high>'
+'<param name="scale" value="scale">'
+'<EMBED src="http://www.mysite.com/forum/style_images/1/Banner.swf' +document.location.search+'" '
+'quality=high scale="scale" WIDTH=755 HEIGHT=50 '
+'TYPE="application/x-shockwave-flash"></EMBED></OBJECT></center>')
break;

case 640:
document.write ('<center><object '
+'codebase=" http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,65,0" '
+'id="Banner" align="center"'
+'WIDTH=595 HEIGHT=45> <PARAM NAME=movie VALUE="Banner.swf'+document.location.search+'">'
+'<PARAM NAME=quality VALUE=high>'
+'<param name="scale" value="scale">'
+'<EMBED src="http://www.mysite.com/forum/style_images/1/Banner.swf' +document.location.search+'" '
+'quality=high scale="scale" WIDTH=595 HEIGHT=45 '
+'TYPE="application/x-shockwave-flash"></EMBED></OBJECT></center>')
break;

}
}
//-->
</script>

Finally, I did not change anything in my software configuration besides upgrading XP. Firewall is disabled in XP since I use another one and did not change the config of that one either. Pop-up blocker is disabled in IE and Opera.

Can you help me out? I can't figure out what is going on.

Sayonara
11-01-2004, 04:21 PM
Best explanation I can think of:

If the code is not being returned to the page source, then none of the conditions in your switch are being met (possibly the screen width is being incorrectly reported, or not reported at all). Try adding a 'default' case which uses the same settings as the 1024 case, and see if that works.

Cybershaolin
11-01-2004, 04:40 PM
I tried adding this: (I use a 1280 x 1024 resolution)

case default:
document.write ('<center><object '
+'codebase=" http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,79,0" '
+'id="Banner" align="center"'
+'WIDTH="1231" HEIGHT="67"> <PARAM NAME=movie VALUE="Banner.swf'+document.location.search+'">'
+'<PARAM NAME=quality VALUE=high>'
+'<param name="scale" value="scale">'
+'<EMBED src="http://www.cyberdbs.com/forum/style_images/1/Banner.swf' +document.location.search+'" '
+'quality=high scale="scale" WIDTH=1231 HEIGHT=67 '
+'TYPE="application/x-shockwave-flash"></EMBED></OBJECT></center>')
break;

Same problem.

You said that the none of my conditions would be met but why did it work before on my computer and why does it work on my two other computers? (One of them uses 1024 x 768 and the other one 800 x 600?

Sayonara
11-01-2004, 05:38 PM
"Default" doesn't use the case keyword, so it will just be default: rather than case "default":.

It might be that those two particular computers you are using are reporting their display settings incorrectly. Why they would do that I am not sure, but if the code is not displaying that suggests the conditions are not being met in your switch, and if the conditions are not being met then either the script is not able to recover the screen width, or the reported screen width is not among the cases you are looking out for (e.g. it might be incorrectly reported as 1023*767. Not sure if that can happen, but it is a possiblity).

Using a default: case in your switch will help you work out what is going on. I suggest you try something like this for now, and see what happens:


default:
document.write ('<p>The default case was called</p>')
break;

Cybershaolin
11-01-2004, 06:39 PM
Thanks for trying to resolve this.

You mean something like this:

This is what I have in my code now:


<script language="JavaScript">
<!--
ecran = screen.width;
image1="Banner+(screen.width).swf"
{
switch(screen.width)
{

default:
document.write ('<center><object '
+'codebase=" http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,79,0" '
+'id="Banner" align="center"'
+'WIDTH="1231" HEIGHT="67"> <PARAM NAME=movie VALUE="Banner.swf'+document.location.search+'">'
+'<PARAM NAME=quality VALUE=high>'
+'<param name="scale" value="scale">'
+'<EMBED src="http://www.mysite.com/forum/style_images/1/Banner.swf' +document.location.search+'" '
+'quality=high scale="scale" WIDTH=1231 HEIGHT=67 '
+'TYPE="application/x-shockwave-flash"></EMBED></OBJECT></center>')
break;

}
}
//-->
</script>

It does the same thing. (I always clear my cache before trying back).

I still see it though on my two other computers but not on mine! I just don't get it.

Sayonara
11-01-2004, 07:35 PM
Is it still not showing the content?

If so I am not sure what is going on :confused:

Cybershaolin
11-01-2004, 08:46 PM
Well, no it does not show it on my computer which has a resolution of 1280 x 1024. If I change my resolution at 1024 x 768 it does not show either. :confused:

It still works on my two other computers with your dafault script, but since the native resolution of the banner is made for 1280x 1024 and these computers have different screen res., it's kind of wide but at least it shows.

This is a really hard problem to track. I don't have any idea what is causing that.

It really sucks. :mad: :(

hemebond
11-01-2004, 08:52 PM
Well this works for me
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>46903</title>
</head>
<body>
<div id="banner"></div>
</body>
<script type="text/javascript">
var object = document.createElement("object");
object.setAttribute("data","http://www.mysite.com/forum/style_images/1/Banner.swf" + document.location.search);
object.setAttribute("type","application/x-shockwave-flash");

/* This is suppose to be for IE, but it doesn't bloody work.
var param = document.createElement("param");
param.setAttribute("name","movie");
param.setAttribute("value",object.getAttribute("data"));
object.appendChild(param);
*/

switch(true)
{
case (window.innerWidth >= 1280):
object.setAttribute("width","1231px");
object.setAttribute("height","67px");
break;

case (window.innerWidth >= 1024):
object.setAttribute("width","986px");
object.setAttribute("height","65px");
break;

case (window.innerWidth >= 800):
object.setAttribute("width","755px");
object.setAttribute("height","50px");
break;

default:
object.setAttribute("width","595px");
object.setAttribute("height","45px");
break;
}
document.getElementById("banner").appendChild(object);
</script>
</html>

Cybershaolin
11-01-2004, 10:01 PM
Not for me. Thanks for trying.

I don't know why my actual script would work on two computers and not on the main one I use. I just changed the video card and since that time I have problems. This is the only thing I have changed, I'm serious. The script worked without any problem before.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum