Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / HTML, CSS, Scripts / JavaScript / October 2005



Tip: Looking for answers? Try searching our database.

Javascript not recognized

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
fishinsanluis@yahoo.com - 28 Oct 2005 18:34 GMT
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.
VK - 29 Oct 2005 10:30 GMT
> 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.
fishinsanluis@yahoo.com - 31 Oct 2005 18:35 GMT
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.
Lee - 31 Oct 2005 18:52 GMT
fishinsanluis@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.
fishinsanluis@yahoo.com - 31 Oct 2005 20:40 GMT
internet explorer
fishinsanluis@yahoo.com - 31 Oct 2005 20:42 GMT
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
Lee - 31 Oct 2005 21:25 GMT
fishinsanluis@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.
fishinsanluis@yahoo.com - 31 Oct 2005 21:35 GMT
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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.