1 Reply Latest reply on Jul 21, 2006 10:15 AM by KevinMcCoy

    Bug in FABridge.js (and suggested fix)

    KevinMcCoy
      I have a page I'm constructing as a prototype, the page contains a Flex SWF, an embedded Acrobat Reader and JavaScript to dynamically alter the PDF's EMBED to display the PDF that corresponds to selected items in the Flex SWF.
      FABridge's code loops through the document's "Embed" tags to retrieve flashVars for every embed, on the assumption that they are all SWF's using the bridge. I've added code to my copy to fix this for the prototype:

      function FABridge__bridgeInitialized(bridgeName)
      {
      var searchStr = "bridgeName="+bridgeName;

      if (/Explorer/.test(navigator.appName))
      {
      var flashInstances = document.getElementsByTagName("Object");

      if(flashInstances.length == 1)
      {
      FABridge.attachBridge(flashInstances[0],bridgeName);
      }
      else
      {
      for(var i=0;i<flashInstances.length;i++) {
      var inst = flashInstances ;
      var params = inst.getElementsByTagName("param");
      for(var j=0;j<params.length;j++) {
      var param = params[j];
      if(param["name"] == "flashvars" && param["value"].indexOf(searchStr) >= 0)
      {
      FABridge.attachBridge(inst,bridgeName);
      }
      }

      }
      }
      }
      else
      {
      var flashInstances = document.getElementsByTagName("Embed");

      if(flashInstances.length == 1)
      {
      FABridge.attachBridge(flashInstances[0],bridgeName);
      }
      else
      {
      for(var i=0;i<flashInstances.length;i++) {
      var inst = flashInstances
      ;
      // try catch added by KDM - embedded PDF broke this
      if (inst.attributes.getNamedItem("flashVars"))
      {
      try
      {
      var flashVars = inst.attributes.getNamedItem("flashVars").nodeValue;
      if(flashVars.indexOf(searchStr) >= 0)
      {
      FABridge.attachBridge(inst,bridgeName);
      }
      }
      catch(e)
      {}
      }

      }
      }
      }
      return true;
      }