Javascript not recognized

F

fishinsanluis

I am having issues with a new window that I create in my application
not executing its Javascript. The js is there in the source and looks
all normal, but it is simply not being recognized. I am running on
Jboss 4.0.2. Here is the code, its simple...


<SCRIPT LANGUAGE="JavaScript">
alert("building image array...");
var image=new Array();
var imageName=new Array();
var name="";
var index=0;
var offset=0;
var isAutoFit=false;


image[0]="\unassociated\DSC00034.JPG";
imageName[0]="DSC00034.JPG";
... (i took this out for brevity's sake, its just populating an
array)
image[29]="\unassociated\SearchVerity";
imageName[29]="SearchVerity";

function autoFit(){
var windowWidth;

if ( isAutoFit ) {
if ( document.body.clientWidth ) {
windowWidth=document.body.clientWidth;
}
else if ( window.innerWidth ) {
windowWidth=window.innerWidth;
}
document.imageGallery.imageslider.width=windowWidth-5;
}
}

function backward(){
if (index > 0){
index--;
}
else {
index=image.length-1;
}
document.imageGallery.imageslider.src=image[index];
document.imageGallery.shortName.value=imageName[index];
}

function forward(){
alert("wow");
if (index < image.length-1) {
index++;
}
else {
index=0;
}

document.imageGallery.imageslider.src=image[index];
document.imageGallery.shortName.value=imageName[index];
}
-->
</SCRIPT>
</HEAD>

<BODY onResize="autoFit()" dir="ltr" bgcolor="#FFFFFF"
style="margin-top:1;margin-bottom:1;margin-left:0;margin-right:0">


<FORM name="imageGallery" method="post">
<TABLE class="report-table" width="100%" border="0"
cellpadding="0" cellspacing="0" dir="ltr">
<TR>
....
<TD class="button-bar-top">
<INPUT class="button-bar-button" type="button" name="backPb"
value="<<Back" onClick="javascript:backward();">
<INPUT class="button-bar-button" type="button" name="nextPb"
value="Next>>" onClick="javascript:forward();">
</TD>
</TR>
</TABLE>
....



thats it...anyone see anything that woulld make it not work? It is in
a window that is opened from a button in the main window, and the html
is dynamically crated using a jsp.
 
V

VK

image[0]="\unassociated\DSC00034.JPG";

The first big error (not saying the only one but let's us fix this
first).

document.image is Image object. You cannot assign string value to
it. But it has .src property you can change. Also you have to use HTTP
path notation with "/" as delimiter and "./" as "level-up and from
there down" indication. So the statement has to be either:

image[0].src = "unassociated/DSC00034.JPG";
// subdir "unassociated" of the current dir

or:

image[0].src = "./unassociated/DSC00034.JPG";
// subdir "unassociated" of the parent dir

Please change all statements accordingly through your script. Please
come back if more errors will be found.
 
F

fishinsanluis

That's not the issue. In fact, this entire thing was working when we
were using Tomcat, but it won't work now. The alert at the beginning
of the js wont even fire, nor will the one whenyou press the forward
button. The images are not the issue.
 
L

Lee

(e-mail address removed) said:
I am having issues with a new window that I create in my application
not executing its Javascript. The js is there in the source and looks
all normal, but it is simply not being recognized. I am running on
Jboss 4.0.2. Here is the code, its simple...


<SCRIPT LANGUAGE="JavaScript">
-->
</SCRIPT>
</HEAD>

It doesn't matter how the code is sent to the browser.
All that matters is what arrives at the browser and how the browser
interprets it.

The <script> tag should be:
<script type="text/javascript">

But that shouldn't really cause a problem.

The line:

-->

is a Javascript syntax error. Get rid of it.
Some browsers will ignore it, but you haven't told us which browser
you're testing with.
 
F

fishinsanluis

i actually already got rid of that...didnt help... New update on the
issue as well. This code works just fine deployed on Tomcat... and the
code is identical. So it seems to be a Jboss issue, not a js issue.
Correct me if you think thats wrong
 
L

Lee

(e-mail address removed) said:
i actually already got rid of that...didnt help... New update on the
issue as well. This code works just fine deployed on Tomcat... and the
code is identical. So it seems to be a Jboss issue, not a js issue.
Correct me if you think thats wrong

The difference must be that JBoss is sending different Javascript code
(and/or different HTML). The browser doesn't care where the code comes
from.
 
F

fishinsanluis

Fixed it. It WAS a jboss issue. File.seperator in the jsp that made
this html/js code was using the backslash instead of forward slash.
Still dont know why, but at least it works now
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top