Javascript & JQuery array length problem-Safari only

I am using this script on a page with jquery loaded  to make an example image slide show. Firefox (15.0.1) runs it properly. Safari (5.1.7) shows an image not loaded icon after the last image then begins at the first image, as though it reads the length as 1 count longer.
<script type='text/javascript'>
                    //this function is a slideshow
                    var imagesArray = ['html5.jpg','uxdesign.jpg','photoshop.jpg','jquery.jpg'];
                    var captionsArray = ['Smashing HTML','Smashing UX Design','Smashing Photoshop','Smashing JQuery'];
                    var active_index=0;
                    var active_Img=imagesArray[active_index];
                    function imageSwitch() {
                              active_index++;
                                   //this is the problem section
                              if(active_index>imagesArray.length){
                                        active_index=0;
                              active_Img=imagesArray[active_index];
                              var newSrc = "images/" + active_Img;
                              $('img.active').attr("src",newSrc);
          $(document).ready(function () {
               setInterval("imageSwitch()",5000);
</script>

Similar problem stands for my website as well. I don't create picture galleries, but link my pdfs to Dropbox. There must be something wrong with Safari and javascript... Chrome and Firefox don't have this problem, everything works fine there.

Similar Messages

  • How to set array length correctly in this case

      class RunJavaCode implements ActionListener{
        public void actionPerformed(ActionEvent e){
          try{
            Process proc=Runtime.getRuntime().exec("java javaapp");
            InputStream input=proc.getInputStream();
            byte[] b=new byte[3000];
            input.read(b);              
            String javaReport=new String(b);
            input.close();
            outputText.setText(javaReport);
          }catch(IOException ioex){System.out.println("IOException is "+ioex);}
      }how to set this array(byte[] b) length correctly? I mean this array length should not only save memory,but also enough to use('enough to use' mean that read outputed info from console to this byte array never overflow)

    Hi,
    you cannot know in advance, how many bytes will be read. But the read-method returns the number of bytes actually read and this is important!
    So at least you have to write:        int r = input.read(b);
            String javaReport=new String(b, 0, r); However, you still do not know, whether there is even more output available. You could however retrieve the data in a loop and append it e.g. to a StringBuffer, until EOF is encountered.

  • Since the last update I have been unable to print from Firefox. No problem printing from Safari or any other program. I've seen a few responses to this problem but only to people running Windows. I'm on a Mac running v. 10.5.8

    Since the last update I have been unable to print from Firefox. No problem printing from Safari or any other program. I've seen a few responses to this problem but only to people running Windows. I'm on a Mac running v. 10.5.8.

    Also when I click on the link in my email to activate my account (in the hopes that a solve will be emailed to me) I get this message -
    "Something is wrong
    We could not activate your account. Please make sure that you have clicked the correct link in your email or typed in the correct address."
    Same message if I cut and paste the link.

  • Problems with getting array length

    I couldn't get array length in the java from the oracle.
    Here is my source.
    Can anybody answer me, I will really appriciate that.
    Thanks.
    public class Test_tb{
    public static double Test (oracle.sql.ARRAY args){
    double ret = 0;
    try {
    Double[] retArr = (Double[]) args.getArray();
    return retArr.length;
    } catch (Exception e){}
    return ret;
    }

    I've rewritten your code to include the display of any exception that might occur. Could you please run it and post any stack trace here? Thanks.
    public class Test_tb{
      public static double Test (oracle.sql.ARRAY args){
      double ret = 0;
      try {
        Double[] retArr = (Double[]) args.getArray();
        return retArr.length;
      } catch (Exception e){}
        e.printStackTrace();
        return ret;
    }

  • How to solve problem - " Safari cannot open page because it isn't connected to the internet" but the airport is ok. signal full and i have n IP address.

    How to solve problem - " Safari cannot open page because it isn't connected to the internet" but the airport is ok. signal full and i have n IP address. and i m using Macbook pro.
    OS snow leopard and above...

    Do you have this problem with all websites, or only some? If only some, which ones?

  • PDF does not display 300 dpi images in Safari only

    I have a dynamically generated PDF that contains a 300 dpi image. The image added can be one of several that the user selects. On all other browsers the pdf renders fine. On Safari only, seemingly in all modern flavors of OSx and Safari, the images begin to print and then  stops printing the actual image and grey is printed in the remaining space the image would take up. To make it more fun one of the images renders fine. It is the 3rd smallest image and the 2 smaller ones do not render so it does not seem to be size related. Hoping someone here has seen this before.
    This is a screenshot to use as an example:
    The folding instructions graphic is also 300dpi.

    Thanks Hackintosh.
    It prints as it views, as a corrupt jpeg. I also dug into console and it confirmed there was an error about a corrupt jpg. The most interesting thing is if I open the bad pdf in Photoshop the whole image is there with no signs of corruption. This leads me to believe it's something with how OSx and/or Safari are rendering the jpgs. Another curious sidenote, Safari on Windows works fine but if you save the pdf, move it to a mac and open it, you get the corrupted jpg again.
    I think I'm going to try and stop swimming upstream now. At the end of the day I don't care if the images are pngs, tiffs, or eps. I'm going to try feeding a few different formats and see if that doesn't fix the problem.

  • Calling1.4.1 signed applet from Javascript causes keyboard/focus problems

    Pretty sure there's a JRE bug here, but I'm posting to forums before I open one in case I'm missing something obvious :-)
    This issue may be specific to IE, I haven't tested elsewhere yet. Our web application is centered around a signed applet that is initialized with XML data via Javascript. We first noticed the problem when our users started upgrading from the 1.3.x plug-in to the 1.4.x plug-in. The major symptom was that shortcut keys stopped working. I debugged the problem off and on for about a month before I boiled it down to a very simple program that demonstrates the issue (included below). Basically, the program has a function that adds a JButton to a JPanel and registers a keyboard listener (using the new DefaultKeyboardFocusManager class) that prints a message to the console. This function is called by the applet's init() method, as well as by a public method that can be called from Javascript (called callMeFromJavascript()). I also included a very simple HTML file that provides a button that calls the callMeFromJavascript() method. You can test this out yourself: To recreate, compile the class below, JAR it up, sign the JAR, and put in the same dir with the HTML file. Load the HTML file in IE 5.0 or greater, and bring the console up in a window right next to it. Now click the button that says init--you should see the small box appear inside the button that indicates it has the focus. Now press some keys on your keyboard. You should see "KEY PRESSED!!!" appearing in the console. This is proper behavior. Now click the Init Applet from Javascript button. It has removed the button called init, and added one called "javascript". Press this button. Notice there is no focus occurring. Now press your keyboard. No keyboard events are registered.
    Where is gets interesting is that if you go back and make this an unsigned applet, and try it again, everything works fine. This bug only occurs if the applet is signed.
    Furthermore, if you try it in 1.3, signed or unsigned, it also works. So this is almost certainly a 1.4 bug.
    Anyone disagree? Better yet, anyone have a workaround? I've tried everything I could think of, including launching a thread from the init() method that sets up the components, and then just waits for the data to be set by Javascript. But it seems that ANY communication between the method called by Javascript and the code originating in init() corrupts something and we don't get keyboard events. This bug is killing my users who are very reliant on their shortcut keys for productivity, and we have a somewhat unique user interface that relies on Javascript for initialization. Any help or suggestions are appreciated.
    ================================================================
    Java Applet (Put it in a signed JAR called mainapplet.jar)
    ================================================================
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class MainApplet extends JApplet implements KeyEventDispatcher
        JPanel test;
        public void init()
            System.out.println("init called");
            setUp("init");
        public void callMeFromJavascript()
            System.out.println("callMeFromJavascript called");
            setUp("javascript");
        private void setUp(String label)
            getContentPane().removeAll();
            test = new JPanel();
            getContentPane().add( test );
            JButton button = new JButton(label);
            test.add( button );
            test.updateUI();
            DefaultKeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(this);
        public boolean dispatchKeyEvent(KeyEvent e)
            System.out.println("== KEY PRESSED!!! ==");
            return false;
    }================================================================
    HTML
    ================================================================
    <form>
    <APPLET code="MainApplet" archive="mainapplet.jar" align="baseline" id="blah"
         width="200" height="400">
         No Java 2 SDK, Standard Edition v 1.4.1 support for APPLET!!
    </APPLET>
    <p>
    <input type="button" onClick="document.blah.callMeFromJavascript();" value="Init Applet via Javascript">
    </form>

    I tried adding the requestFocus() line you suggested... Same behavior.
    A good thought, but as I mention in my description, the applet has no trouble gaining the focus initially (when init() is called). From what I have seen, it is only when the call stack has been touched by Javascript that I see problems. This is strange though: Your post gave me the idea of popping the whole panel into a JFrame... I tried it, and the keyboard/focus problem went away! It seems to happen only when the component hierarchy is descended from the JApplet's content pane. So that adds yet another variable: JRE 1.4 + Signed + Javascript + components descended from JApplet content pane.
    And yes, signed or unsigned DOES seem to make a difference. Don't ask me to explain why, but I have run this little applet through quite a few single variable tests (change one variable and see what happens). The same JAR that can't receive keyboard events when signed, works just fine unsigned. Trust me, I'm just as baffled as you are.

  • Javascript is not working in Safari on my iPad, version 6.1.3. Anyone know why?

    I have an iPad with os version 6.1.3.  Javascript on websites is not working in Safari. Does anyone know why? How can I correct this situation?

    It is jquery libraries that are not functioning properly and some of the html.  I have Javascript turned on.  The website was working in Safari.  I tested it in Safari and I viewed it many times using Safari and it worked.  I went on to it on 5/8/13 and the javascript/jquery portion and parts of the html are not working.  It had been tested about 4 or 5 months ago in several diffierent versions of IE, Chrome, Mozilla and Safari. 
    Thanks for responding to my question

  • Dreamweaver template files updating, but javascript/jquery not being called on random pages.

    Hello,
    I have been tasked with updating the navigation on a site that is using a Dreamweaver template (DWT) as the base file. The navigation was originally built using jQuery navigation UI, however this did not address all of our needs and I have updated it with another version of an accordion.
    The .dwt file only is only controlling the navigation and the head of the site.
    I have integrated the new xhtml structure and added/removed javascript/jquery into the .dwt file. I saved the file, therefore updating all of the relevant .html files, and verified that the accordion works.
    However - the accordion does not work for all of the xhtml files. Some files, seemingly at random, are not pulling in the javascript.
    When opening the relevant .html files, I can verify that they have all been updated with the new xhtml and the correct javasctipt. However, when viewing the .html files that are not displaying correctly with FireBug, I can see that none of the jquery/javascript is being applied to the navigation (classes are missing that are injected into the xhtml, but the structure and css is correct).
    I've done some research and the only issues I've been able to find are related to .xhtml files not being updated with the correct code, but in my case all of the affected files have the correct xhtml and scripts in the head.
    Does anyone have any light to shed on this subject? I am quite puzzled.

    While I understand that looking at code is the ultimate way to find a solution, the intent of my question was not "how do i fix this" or "what is wrong with my code" but rather "does anyone have any idea as to why this would be happening". Or even, "where would you start to troubleshoot this".
    I made my question general as such because I intended on trying to troubleshoot on my own in order to better understand the issue.
    Thank you for stating the obvious, not all first time forum posters are completely unaware of how to ask questions properly.

  • How tp pass javascript variables/arrays to a servlet?

    Plz help me in passing javascript variables/arrays to a servlet

    Hi,
    I am creating table rows & columns containg text fields dynamically as follows:
    function addRowToTable()
    var tbl = document.getElementById('tblSample');
    var lastRow = tbl.rows.length;
    // if there's no header row in the table, then iteration = lastRow + 1
    var iteration = lastRow;
    var row = tbl.insertRow(lastRow);
    // right cell
    var cellRight = row.insertCell(0);
    var el = document.createElement('input');
    el.type = 'text';
    el.name = 'txtRow' + iteration;
    el.id = 'txtRow' + iteration;
    el.size = 20;
    cellRight.appendChild(el);
    Now i am calling function addRowToTable() from jsp page as + key is pressed to add rows dynamically.
    So as per rows different textfields are also getting created dynamically with different id & name.
    Now i am getting session attributes containing the values for textfields from servlet.
    but i am not able to map the values for dynamic textfields getting created?
    I want to print values in appropriate fields.
    Plz help me.

  • Maximum array length in javacard

    hi all
    i have a java class with 20 member variables.
    member variables are array of bytes. i doesn't allocate
    memory for this variables in class constructor,
    memory for this variables is dynamically allocated
    in my javacard applet (*runtime*).
    i defined an array of this class in my applet( in applet constructor):
    myclassArray = new myclass[MAX]
    for ( short i =0; i < MAX; i++ )
        myclassArray[i] = new myclass();myclass.java:
           class myclass {
                 byte[] membervariable1;
                  setVar1( byte[] input) {
                   membervariable1 = input;
            }if MAX >= 100 , i can't load applet on the card.
    (error :conditions of use not satisfied)
    why this problem occurs? my card is 32k and i doesn't allocate memory for myclass member variables in applet constructor;
    maybe an array of class in javacard has a maximum value in its length. am i right?
    thanks,
    siavash

    s.fallahdoost wrote:
    hi all
    i have a java class with 20 member variables.
    member variables are array of bytes. i doesn't allocate
    memory for this variables in class constructor,It doesn't look like it. If you look at the code snippet below, which is located in the constructor, you are allocating memory in the loop.
    memory for this variables is dynamically allocated
    in my javacard applet (*runtime*).Does not like it neither. If you look at your second code snippet, you're jusr re-referencing the pointer to another instance.
    i defined an array of this class in my applet( in applet constructor):
    myclassArray = new myclass[MAX]
    for ( short i =0; i < MAX; i++ )
    myclassArray[i] = new myclass();myclass.java:
    class myclass {
    byte[] membervariable1;
    setVar1( byte[] input) {
    membervariable1 = input;
    }if MAX >= 100 , i can't load applet on the card.
    (error :conditions of use not satisfied)Could be, since you're allocating memory in the constructor.
    why this problem occurs? my card is 32k and i doesn't allocate memory for myclass member variables in applet constructor;
    maybe an array of class in javacard has a maximum value in its length. am i right?The maximum array length is 32k.

  • Finding Array Length

    I was just wondering if i have an array
    double [][][] array = new double [1][2][3];array.length only gives 1, what function can i use to find the size of the other dimensions (2 and 3)? Thanks in advance for any help.

    I'll try and explain this a little better.
    Say array[0].length is 2, then that means that there is only
    array[0][0] and array[0][1].
    If array[0][0] is 4, then that means that there is only
    array[0][0][0], array[0][0][1], array[0][0][2], and array[0][0][3].
    The reason i did array[0][0].length and not array[0][1].length
    in my other post is because they would both return the same
    thing because of the way you declared the array.
    When you dodouble[][] array = new double[2][3];this is making it so that array[0].length is 3 and array[1].length is 3.
    But if you do this (shown in the previous post)
    double[][] aray = {
        { 2.4, 5.6, 6.4 },
        { 1.4 }
    }then array[0].length is 3, but array[1].length is 1.
    Hope this helps.

  • Maximum possible ARRAY LENGTH ?!?!

    Hello All
    How can I know (before allocating memory) what is the maximum possible array length. Does it depend on the JVM version or OS or something else ???
    Please help !

    Thanx All !!!
    I've moved to more "memory saving" algorithm, so there is no problem now :-))
    But another 2 questions has poped up: I'm using a Vector object in a pretty long loop (millions of iterations) and once in a while accumulating some data (Long and Double objects) by adding them to the Vector.
    1. What can be the maximum possible vector length ?
    2. What's faster: using a Vector object or using a regular "long or double" array that should be reallocated as:
    double[] arr = new double[****];
    for(long i=0; i<Long.MAX_VALUE; i++)
        // add new elem
        double[] tmp = new double[arr.length+1];
        System.arraycopy(arr, 0, tmp, 0, arr.length);
        tmp[tmp.length] = newElem;
        arr = tmp;  
    }

  • Safari only opens blank pages

    Please help! My safari will not load any pages. It attempts to load a page but nothing happens. It seems to stall when loading... I can open a new tab but every address I type in will not load. I've tried to force quit- no luck. I've tried to log into safari a as guest and check safari and no luck. I rebooted, and even safe mode rebooted and no luck. What should I try next?

    Please read this whole message before doing anything.
    This procedure is a test, not a solution. Don’t be disappointed when you find that nothing has changed after you complete it.
    Step 1
    The purpose of this step is to determine whether the problem is localized to your user account.
    Enable guest logins* and log in as Guest. Don't use the Safari-only “Guest User” login created by “Find My Mac.”
    While logged in as Guest, you won’t have access to any of your personal files or settings. Applications will behave as if you were running them for the first time. Don’t be alarmed by this; it’s normal. If you need any passwords or other personal data in order to complete the test, memorize, print, or write them down before you begin.
    Test while logged in as Guest. Same problem?
    After testing, log out of the guest account and, in your own account, disable it if you wish. Any files you created in the guest account will be deleted automatically when you log out of it.
    *Note: If you’ve activated “Find My Mac” or FileVault, then you can’t enable the Guest account. The “Guest User” login created by “Find My Mac” is not the same. Create a new account in which to test, and delete it, including its home folder, after testing.
    Step 2
    The purpose of this step is to determine whether the problem is caused by third-party system modifications that load automatically at startup or login, by a peripheral device, or by corruption of certain system caches.
    Disconnect all wired peripherals except those needed for the test, and remove all aftermarket expansion cards. Boot in safe mode and log in to the account with the problem. Note: If FileVault is enabled on some models, or if a firmware password is set, or if the boot volume is a software RAID, you can’t do this. Ask for further instructions.
    Safe mode is much slower to boot and run than normal, and some things won’t work at all, including sound output and Wi-Fi on certain models.  The next normal boot may also be somewhat slow.
    The login screen appears even if you usually log in automatically. You must know your login password in order to log in. If you’ve forgotten the password, you will need to reset it before you begin.
    Test while in safe mode. Same problem?
    After testing, reboot as usual (i.e., not in safe mode) and verify that you still have the problem. Post the results of steps 1 and 2.

  • Get Type ArrayElement  fails if array length is 0

    All:
    Get<Type>ArrayElement fails if the array length is 0 in 1.4. It seems to work fine in 1.5. I was "googling" and I found this link -- http://e-docs.bea.com/wljrockit/v315/relnotes/relnotes.htm. It mentions that this problem -- The JNI methods GetStringChars and Get<>ArrayElements threw OutOfMemoryError if called with a String or array of zero length -- was fixed in version 3.1.4. What is version 3.1.4 and how does this relate to JDK verions that I get out of java -version.
    I will appreciate any pointers.
    M.P. Ardhanareeswaran
    Oracle USA

    Drag and drop within a datagrid is rather an unusual thing to do.
    I would suggest your problem lies in choosing to do something which will cause complications.
    Hope that helps.
    Recent Technet articles: Property List Editing;
    Dynamic XAML

Maybe you are looking for