Loading ...
Sorry, an error occurred while loading the content.

37340Re: Flex widget inside layout manager cannot be called from javascript in IE

Expand Messages
  • aniad
    Sep 5, 2008
    • 0 Attachment
      Dav,

      Thank you for your reply. Unfortunately, changing the code does not
      solve this issue.
      I've changed the code to use object/embed tags instead of doing
      document.write, and I continue to have the same problem.
      My code looks like this now:

      <script>
      var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;

      function callFlex()
      {
      var widgetId = "flexIdgetIE";
      if ( isIE )
      widgetId = "flexWidgetIE";

      // This will not work if layout was created and the Flex widget is
      hosted inside it.

      document.getElementById(widgetId).Flex_TestExternalInterface("one","two");
      }

      function initLayout()
      {
      layout = new YAHOO.widget.Layout('layoutDiv',
      {
      height: 500,//800,
      //minWidth: 1000,
      units: [
      // Switching these two lines shows the problem. If
      the div with flex is shown inside the layout then it cannot be called
      (callFlex() fails)
      // if it is shown outside of layout then it works
      properly.
      { position: 'center', header: "I do not work", height:
      490, scroll: false, resize: true, body: 'centerDivWithFlex', gutter:
      '2px 5px', collapse: true, collapseSize: 50, maxWidth: 1000 }
      //{ position: 'center', header: "I do work", height:
      490, scroll: false, resize: true, body: 'centerDivWithoutFlex',
      gutter: '2px 5px', collapse: true, collapseSize: 50, maxWidth: 1000 }
      ]
      });

      layout.render();

      }

      YAHOO.util.Event.onDOMReady(initLayout);

      </script>
      <body class=" yui-skin-sam">
      <div id="layoutDiv" height="100%" width="99%"></div>
      <div id="centerDivWithoutFlex" height="100%" width="99%">I am center</div>

      <div id="centerDivWithFlex" style="height:500px;width:100%">

      <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
      id="flexWidgetIE" width="100%" height="100%"

      codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">
      <param name="movie" value="TestExternalInterface.swf" />
      <param name="quality" value="high" />
      <param name="bgcolor" value="#869ca7" />
      <param name="allowScriptAccess" value="always" />
      <comment>
      <embed src="TestExternalInterface.swf" quality="high"
      bgcolor="#869ca7"
      width="100%" height="100%" id="flexWidget" name="flexWidget"
      align="middle"
      play="true"
      loop="false"
      quality="high"
      allowScriptAccess="always"
      type="application/x-shockwave-flash"
      pluginspage="http://www.adobe.com/go/getflashplayer">
      </embed>
      </comment>
      </object>

      </div>

      <button onclick="callFlex();">Click me</button>
      </body>


      Ania.



      --- In ydn-javascript@yahoogroups.com, Dav Glass <dav.glass@...> wrote:
      >
      > aniad --
      >
      > The issue is that your script is doing a document.write of the embed
      tags into the div "centerDivWithFlex".
      > Then when the Layout is rendered, it's moving it in the DOM.
      > IE (and most browsers) don't like it when you do that..
      >
      > What you need to do, it remove the use of document.write and use DOM
      to add the embed info to the div
      > AFTER the layout is rendered by listening to the Layout's render event..
      >
      > layout.on('render', initFlex);
      >
      > Does that make sense?
      > Dav
      >
      > Dav Glass
      > dav.glass@...
      > blog.davglass.com
      >
      >
      >
      >
      > + Windows: n. - The most successful computer virus, ever. +
      > + A computer without a Microsoft operating system is like a dog
      > without bricks tied to its head +
      > + A Microsoft Certified Systems Engineer is to computing what a
      > McDonalds Certified Food Specialist is to fine cuisine +
      >
      >
      >
      > ----- Original Message ----
      > > From: aniad <aniad@...>
      > > To: ydn-javascript@yahoogroups.com
      > > Sent: Friday, September 5, 2008 11:14:27 AM
      > > Subject: [ydn-javascript] Re: Flex widget inside layout manager
      cannot be called from javascript in IE
      > >
      > > Hi Dav,
      > >
      > > I don't mean to come off impatient, but w/o some insight into this
      > > problem our app will not work in IE. I will very much appreciate any
      > > advise/observations you might have.
      > > a.
      > >
      > > --- In ydn-javascript@yahoogroups.com, "aniad" wrote:
      > > >
      > > > Hello Dav,
      > > >
      > > > I don't really have a site available that is outside of a
      firewall, so
      > > > I have a zip file for you here:
      > > >
      > > > https://download.amberpoint.com/forYahoo/forYUI.zip
      > > > Username: Yahoo
      > > > Password: bug4yahoo
      > > >
      > > > Please put these files on some server and then access
      > > > flexInLayoutProblem.html (it has to be accessed via some server,
      > > > localhost for example, not local file system, otherwise flex
      runs into
      > > > security problems)
      > > >
      > > > As I've commented in that .html file, if you create the flex widget
      > > > outside of the layout manager then calling it in IE is not a
      problem.
      > > > However, putting the flex widget inside the layout prevents it from
      > > > being able to be called in IE. It works fine in Firefox.
      > > >
      > > > I've also included TestExternalInterface.zip which is the source for
      > > > the simple flex widget.
      > > >
      > > > Please advise.
      > > > Ania.
      > > >
      > > >
      > > >
      > > > --- In ydn-javascript@yahoogroups.com, Dav Glass wrote:
      > > > >
      > > > > aniad --
      > > > >
      > > > > Please post a link so I can see it, the code doesn't help me if I
      > > > can't see the issue :D
      > > > >
      > > > > Thanks
      > > > > Dav
      > > > >
      > > > > Dav Glass
      > > > > dav.glass@
      > > > > blog.davglass.com
      > > > >
      > > > >
      > > > >
      > > > >
      > > > > + Windows: n. - The most successful computer virus, ever. +
      > > > > + A computer without a Microsoft operating system is like a dog
      > > > > without bricks tied to its head +
      > > > > + A Microsoft Certified Systems Engineer is to computing what a
      > > > > McDonalds Certified Food Specialist is to fine cuisine +
      > > > >
      > > > >
      > > > >
      > > > > ----- Original Message ----
      > > > > > From: aniad
      > > > > > To: ydn-javascript@yahoogroups.com
      > > > > > Sent: Tuesday, September 2, 2008 10:54:42 AM
      > > > > > Subject: [ydn-javascript] Flex widget inside layout manager
      cannot
      > > > be called from javascript in IE
      > > > > >
      > > > > > Hello,
      > > > > >
      > > > > > I'm having a real problem with Layout Manager hosting a flex
      > > widget in
      > > > > > the center pane in IE. Specifically the problem has to do with
      > > > > > javascript calling flex. The flex widget registers javascript
      > > > > > callbacks which work fine in Firefox. However they do not in
      > > IE. The
      > > > > > problem is directly related to the Layout Manager, as
      > > eliminating the
      > > > > > Layout, ie putting the flex widget just in a simple
      > > > > , solves the
      > > > > > problem.
      > > > > >
      > > > > > My code looks something like:
      > > > > >
      > > > > > function initLayout()
      > > > > > {
      > > > > > layout = new YAHOO.widget.Layout('layoutDiv',
      > > > > > {
      > > > > > height: 500,//800,
      > > > > > units: [
      > > > > > { position: 'center', height: 490, scroll:
      false,
      > > > > > resize: true, body: 'selectorDiv', gutter: '2px 5px', collapse:
      > > true,
      > > > > > collapseSize: 50, maxWidth: 1000 }
      > > > > > ]
      > > > > > });
      > > > > >
      > > > > > }
      > > > > >
      > > > > > Function callFlex()
      > > > > > {
      > > > > > Document.getElementById("myFlexWidget").Flex_SetView(); //
      > > > > > "Flex_SetView" is a registered callback in action script
      > > > > > }
      > > > > >
      > > > > > YAHOO.util.Event.onDOMReady(initLayout);
      > > > > >
      > > > > >
      > > > > >
      > > > > > show flex problem
      > > > > >
      > > > > >
      > > > >
      > > > > >
      > > > > >
      > > > > >
      > > > > >
      > > > > >
      > > > > >
      > > > > > The error in IE is "Unspecified Error" in some IE javascript
      code:
      > > > > >
      > > > > > function __flash__addCallback(instance, name) {
      > > > > > instance[name] = function () {
      > > > > > return eval(instance.CallFunction(">
      > > > returntype=\"javascript\">" + __flash__argumentsToXML(arguments,0) +
      > > > > > ""));
      > > > > > }
      > > > > > }
      > > > > >
      > > > > > Both params, instance and name are valid. We found this
      article on
      > > > > > the subject, http://www.airtightinteractive.com/news/?p=71, and
      > > we are
      > > > > > already doing everything suggested in this article. Again, as
      > > stated
      > > > > > above, eliminating the layout manager allows the flex
      callbacks to
      > > > > > work again.
      > > > > >
      > > > > > Please advise, thank you!
      > > > > >
      > > > > > Ania.
      > > > > >
      > > > > >
      > > > > >
      > > > > >
      > > > > > ------------------------------------
      > > > > >
      > > > > > Yahoo! Groups Links
      > > > > >
      > > > > >
      > > > > >
      > > > >
      > > >
      > >
      > >
      > >
      > > ------------------------------------
      > >
      > > Yahoo! Groups Links
      > >
      > >
      > >
      >
    • Show all 9 messages in this topic