1 Reply Latest reply on Apr 3, 2014 6:11 AM by TLCMediaDesign

    Time Line action / Get the image in javascript.

    SinchEid

      HI All, i need to hide a image and text box if the user view the course in Ipad. i dont want to create two build and do this, finally i got an idea to do it. i create a javascript function in slide action panel(when enter). i can able to find it now whether user is viewing the page in Ipad or not. same time i created a variable in CP and am setting the value to 1 when its Ipad. i used follow script to do this.

       

      var i, e, varValue, varName, objCp,iPadMobile,isHTML5=false;

      function CheckPlatform(){

       

       

       

       

                if (typeof window.cp==='undefined') {

                          objCp=document.getElementById('Captivate');

       

       

                          if(objCp && objCp.cpEIGetValue){

                                    isHTML5 = false;

       

       

                          }

                } else {

                          /* We have HTML5 output */

                          if(cp.vm && cp.vm.getVariableValue){

                                    isHTML5 = true;

                                    if( /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent) ) {

                                              iPadMobile = true

                                    }

                                    else{

                                    iPadMobile = false

                                              }

                          }

                }

       

      }

       

       

      CheckPlatform();

      alert(isHTML5)

      function checkVariable(){

       

                if(isHTML5){

             if(iPadMobile){

       

                           cp.vm.setVariableValue("CheckDevice", 1);

                           //document.getElementById('Captivate').getElementsByClassName("baby").style.visibility="h idden";

                     //document.getElementsByClassName("baby").style.display ="none";

                     alert("img"+document.getElementsByClassName("baby"))

       

                           }

                           else{

                                    cp.vm.setVariableValue("CheckDevice", 0);

                                    }

       

                          varValue = cp.vm.getVariableValue("CheckDevice");

       

                }

                else{

                alert("test")

                objCp.cpEISetValue('m_VarHandle.CheckDevice', 0);

                varValue = objCp.cpEIGetValue('m_VarHandle.CheckDevice');

                alert("varValue"+varValue)

       

                }

      }

       

       

      checkVariable();

      //alert(test+"============"+objCp)

       

       

       

      can anyone help me how to hide the image, my image name is baby. how to add timeline action?. i thought of hiding the image in javascrio but that also not working.

        • 1. Re: Time Line action / Get the image in javascript.
          TLCMediaDesign Adobe Community Professional

          I don't think there is going to be a class specified for your image. You're going to have to find what the tag is for the image first in the html5 output. You can get a list of all of the divs, then find the name:

           

          var divs = document.getElementsByTagName("div"); //used to reference divs with no ID or name

          var myBaby = document.getElementById("divName"); //the name is not always the name used in Captivate

           

          Captivate may append a letter to the Instance name you used in Captivate.

           

          Sometimes the elements in the output do not have names or ID's so you'll need to find a div that has a name of ID that contains the image and reference that image as a child of the div node.

           

          var thisDiv = document.getElementById("known name");

          var divNodes = thisDiv.childNodes;

          var myBaby = divNodes[0];