5 Replies Latest reply on May 19, 2011 1:22 PM by Tframe01

    Captivate 5: Problems with Java Scripts - Trying to Jump to a certain slide on Different Project

    Tframe01 Level 1

      I have the code here I researched for Captivate 5 to jump to a certain slide in a different project, this code was attempted to be used in both projects seperately and simultaniously:

       

      function GetSlideParam(){
      if(window.location.href.indexOf('?slide=') != -1) {
        var startIndex = window.location.href.indexOf('?slide=' ) + 7;
        var URL = window.location.href.toString();
        var slideNumber = URL.substring(startIndex);
        
        if(slideNumber != '' || slideNumber != undefined){
         setTimeout(function(){NavigateToSlide(slideNumber);}, 200);
        }

      }
      }

      function NavigateToSlide(requestedSlide){
      var cpObj = document.Captivate;
      cpObj.cpEISetValue('cpCmndGotoSlide',requestedSlide - 1);
      cpObj.cpEISetValue('rdcmndResume',1);
      }

      GetSlideParam();

       

      Here's my on success URL file in the button properties that was needed to jump to that certain slide according to my research:

       

      (my project to jump to).htm?slide=2

       

      In the end, it didn't work and just jumped to slide 1 on the other project no matter what I tried to do or how I altered the script and the project button and slide properties... Please Help... Just thought maybe you guys would know some more about scripting, that's why I'm asking you guys this regardless of it being a Captivate question because the Captivate Specialists couldn't answer my question being clueless about the scripting part of it.

        • 1. Re: Captivate 5: Problems with Java Scripts - Trying to Jump to a certain slide on Different Project
          [Jongware] Most Valuable Participant

          Tframe01 wrote:

           

          ... Just thought maybe you guys would know some more about scripting, that's why I'm asking you guys this regardless of it being a Captivate question because the Captivate Specialists couldn't answer my question being clueless about the scripting part of it.

           

          So the InDesign Scripting Forum is the place to ask about Javascript -- for any other program? Well, paint me red and call me Admiral Ackbar, I didn't see that one coming.

           

          Are you (and with you those "Captivate Specialists") aware of the fact that

           

          var slideNumber = URL.substring(startIndex);

           

          will return a text string, not a number? And so this next operation will (silently) fail, and return some default number instead (most likely, 0)?

           

          (stuff --) requestedSlide - 1
          

           

          If you already knew this, you will have to be more clear on what happens now, what you'd like to happen, and what Captivate actually is supposed to do (since I have no idea what it is).

          • 2. Re: Captivate 5: Problems with Java Scripts - Trying to Jump to a certain slide on Different Project
            Tframe01 Level 1

            Well you did help me more than anyone else confirming a problem with the java script itself, and you are right that no one knew that startindex = 0. So, it sounds like the variable "startindex" is supposed to be something different that will be placed in the variable "slideNumber"? and that variable "startindex" is supposed to be the secret code in the script I'm supposed to find from the slide number in the other project I'm trying to jump to or is it easier than that where I'm just supposed to put in a certain code that is known by the java script specialists? I'm sorry if this doesn't make sense, I have yet to have true experience in scripting obviously by the way I describe this problem.

            • 3. Re: Captivate 5: Problems with Java Scripts - Trying to Jump to a certain slide on Different Project
              John Hawkinson Level 5

              and that variable "startindex" is supposed to be the secret code in the script I'm supposed to find from the slide number in the other project I'm trying to jump to or is it easier than that where I'm just supposed to put in a certain code that is known by the java script specialists? I'm sorry if this doesn't make sense, I have yet to have true experience in scripting obviously by the way I describe this problem.

              Your sentence is hard to understand, but it is not because of your unfamiliarity with scripting.

              Can you please rewrite the above paragraph with smaller shorter sentences?

              Please read it and make sure it makes sense. Because I'm having a lot of trouble.

              • 4. Re: Captivate 5: Problems with Java Scripts - Trying to Jump to a certain slide on Different Project
                [Jongware] Most Valuable Participant

                There is no "secret code". It's all in your handling of the function NavigateToSlide, and some applied logic. (Javascript logic, to be precise.)

                 

                The variable going in is of type "string", and I'm 100% sure of that because you are using the function "substring" to create its argument. I'm that sure because "substring" will always return a string, even when you feed it a boolean or an integer (in those cases it will return an empty string, but that's still a string -- kind of like the number 0 may represent 'nothing at all', but it's still a number).

                 

                Look in the function NaviatgeToSLide. What happens when you subtract 1 from a string? ... Uh. It depends on the language, really. Most languages will report this as an error, but Javascript does not (for various reasons -- if it bothers you, use Google to find out why).

                 

                Now assuming the variable 'requestedSlide' contains a valid slide number and it is stored as a string, how would you convert this to an actual number? Using a pretty basic Javascript function, actually:

                 

                cpObj.cpEISetValue('cpCmndGotoSlide',parseInt(requestedSlide) - 1); 

                 

                Needless to say I'm not 100% sure this will fix the problem, because I cannot test your code using InDesign.