By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,359 Members | 1,543 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,359 IT Pros & Developers. It's quick & easy.

Javascript not recognized

P: n/a
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=windowWidt h-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.

Oct 28 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
VK
> image[0]="\unassociated\DSC00034.JPG";

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

document.image[i] 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.

Oct 29 '05 #2

P: n/a
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.

Oct 31 '05 #3

P: n/a
Lee
fi***********@yahoo.com 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.

Oct 31 '05 #4

P: n/a
internet explorer

Oct 31 '05 #5

P: n/a
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

Oct 31 '05 #6

P: n/a
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

Oct 31 '05 #7

P: n/a
Lee
fi***********@yahoo.com 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.

Oct 31 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.