Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript code is displayed on the screen

Status
Not open for further replies.

chrisjh

Programmer
Dec 24, 2001
3
0
0
CA
We are having a problem with Javascript code being displayed on the user's screens.
We are using iPlanet version 4.1. as a web server.
When we first load our application and click on a page that uses a function to deal with rollovers generated by Dream Weaver,
instead of parsing the function correctly, it dispalys it on the screen.
It doesn't throw a Javascript error and nothing turns up in Debug.
If I reload the page the problem corrects itself and won't occur again during the session.
This didn't happen on Netscape Enterprise server and has only developed since we upgraded to iPlanet 4.1.
The functions are in a js file that is referenced at the beginning of the page.
If I clear my cache, I can replicate the problem.
I removed the code from the functions and the problem stopped except where the functions are explicitly defined in a page.
Then I run into the same problem.

The functios involved are as follows:

function MM_preloadImages() {
if (document.images) {
var imgFiles = MM_preloadImages.arguments;
var preloadArray = new Array();
for (var i=0; i<imgFiles.length; i++) {
preloadArray = new Image;
preloadArray.src = imgFiles;
}
}
}



function MM_swapImage() {
var i,j=0,objStr,obj,swapArray=new Array,oldArray=document.MM_swapImgData;
for (i=0; i < (MM_swapImage.arguments.length-2); i+=3) {
objStr = MM_swapImage.arguments[(navigator.appName == 'Netscape')?i:i+1];
if ((objStr.indexOf('document.layers[')==0 && document.layers==null) ||
(objStr.indexOf('document.all[') ==0 && document.all ==null))
objStr = 'document'+objStr.substring(objStr.lastIndexOf('.'),objStr.length);
obj = eval(objStr);
if (obj != null) {
swapArray[j++] = obj;
swapArray[j++] = (oldArray==null || oldArray[j-1]!=obj)?obj.src:eek:ldArray[j];
obj.src = MM_swapImage.arguments[i+2];
}
}
document.MM_swapImgData = swapArray; //used for restore
}


function MM_swapImgRestore() { //v1.2
if (document.MM_swapImgData != null)
for (var i=0; i<(document.MM_swapImgData.length-1); i+=2)
document.MM_swapImgData.src = document.MM_swapImgData[i+1];
}

Has anybody run into this problem? Does anybody have any suggestions as to how to cure it?
My users are starting to get annoyed at having to always reload a page when garbage appears on the screen.

Thanks

Chris
 
<script language=&quot;javascript&quot;>
<!--
// place script here
-->
</script>

tadam
regards someone knowledge ends were
someone else knowledge starts
 
neversleep,

perhaps i didn't explain myself clearly. The js file is referenced as follows:
<script language=&quot;JavaScript&quot; src=csjs/buttons.js></script>

When the function is explicitly defined in a page, it is enclosed in script tags.

Thanks

Chris
 
buttons.js source:
<!--
//code here
-->
end:

your question is &quot;how do i hide js from old browsers&quot; no?
here it is someone knowledge ends were
someone else knowledge starts
 
How many images are you loading? How large are the images? I seem to remember a problem we had a lot like this one and it was caused by trying to load too many large images. Try reducing the number of images and or thier file size and see if that works.

RnK
 
verify your mime settings in Iplanet. If you are sending files with extension .js it might be what is screwing up. However could you tell us what your browser is and if it does it with a new browser? Gary Haran
 
The images are 1K gifs for displaying a rollover effect on a button.
The browser we are using is Netscape 4.76-4.79 (unfortunately - work for a large company)
I am not trying to hide code from old browsers. The code only displays when we first access the application. After that it works fine. It is almost as if it is expecting something to be cached and when it isn't it interprets the javascript as text.

Chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top