ouyang789987 / swfobject

Automatically exported from code.google.com/p/swfobject
0 stars 0 forks source link

IO Error in Lotus Notes browser #503

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Enter the page with chart
2. Refresh the page
3.

What is the expected output? What do you see instead?
Initial empty chart expected, in reality chart(s) is loaded when entering the 
page for the very first time but when refreshed (or closed and re-entered) it 
produces the well known error:

Open Flash Chart
IO ERROR
Loading test data
Error #2032
This is the URL that I tried to open:../../data-files/y-axis-auto-steps.txt

What version of the product are you using? On what operating system?
SWFObject v2.1; Windows XP SP3; Lotus Notes 8.5

Please provide any additional information below.
Using the OFC2 tutorial where a chart is loaded without swfobject the charts 
are working fine, but when done with swfobject it has the above mentioned 
scenario.

Original issue reported on code.google.com by martins....@gmail.com on 27 Sep 2010 at 11:04

GoogleCodeExporter commented 9 years ago
An IO Error indicates the Flash file didn't properly load the txt file (which 
would not be a swfobject bug). This may be an implementation error. Please post 
your issue to the SWFObject Google Group.

Original comment by platelu...@gmail.com on 7 Nov 2010 at 6:51

GoogleCodeExporter commented 9 years ago
I overcame this issue by not using swfobject for microsoft type browsers, which 
Lotus notes uses. This is the whole code that will work on all browsers. If 
it's IE I include the open-flash-chart.swf directly into an <object>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <link href="css/style.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
    <script type="text/javascript" src="js/json2.js"></script>
    <script type="text/javascript" src="js/swfobject.js"></script>
        <title></title>
    <script type="text/javascript">
        var GLOBAL_CHART = {"elements": []};

        function ofc_ready(){
        }
        function open_flash_chart_data(){
        return JSON.stringify(GLOBAL_CHART);
        }

        function findSWF(movieName) {
        if (navigator.appName.indexOf("Microsoft")!= -1)
            return window[movieName];
        else
            return document[movieName];
        }

        $(document).ready(function(){
        if (navigator.appName.indexOf("Microsoft")!= -1){
            //do nothing
        } else{
            swfobject.embedSWF("open-flash-chart.swf", "chartArea", "0", "0", "9.0.0","","", {wmode: 'Transparent'});
        }
        });
    </script>
    </head>
    <body>
    <?php
    if (isset($_SERVER['HTTP_USER_AGENT']) && (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false)){ // IE
    ?>
        <div id="chartOne">
        <div id="secTitle"><span>SEC TITLE</span></div>
        <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
            codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"
            id="chartArea" align="middle">
            <param name="allowScriptAccess" value="sameDomain" />
            <param name="movie" value="open-flash-chart.swf" />
            <param name="quality" value="high" />
            <param name="wmode" value="transparent"/>
            <embed src="open-flash-chart.swf" wmode="transparent" name="chartArea" allowScriptAccess="sameDomain"
               type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
        </object>
        </div>
    <?php
    } else{
    ?>
        <div id="chartOne">
        <div id="secTitle"><span>SEC TITLE</span></div>
        <div id="chartArea">Adobe Flash is required to view the charts.</div>
        </div>
    <?php
    }
    ?>
    </body>
</html>

Original comment by martins....@gmail.com on 8 Nov 2010 at 9:27

GoogleCodeExporter commented 9 years ago
Thanks for the follow-up. 

An observation: You have the SWF size set to 0px width and 0px height in non-IE 
browsers but don't specify a width/height in IE. In some browsers, when the SWF 
is hidden (whether via setting to 0px/0px or using CSS to hide) 
ExternalInterface will be disabled and your attempts to communicate with your 
SWF will fail. This may be the cause of the error.

Original comment by platelu...@gmail.com on 8 Nov 2010 at 5:27

GoogleCodeExporter commented 9 years ago
Sorry, I should have mentioned I am defining dimensions within the css file.

I just tested using swfobject within Lotus Notes with the dimensions set and it 
is still showing IO Error, whilst working fine in IE and non-IE browsers.

As I have stated in my error report: "chart(s) is loaded when entering the page 
for the very first time but when refreshed (or closed and re-entered) it 
produces the well known error". The browser loads the chart again when changes 
are done to the code, or in matter of fact, whenever it feels like it. It would 
sometimes toggle on and off, showing and not showing when the page is refreshed 
(with swfobject being used), but in most cases not displayed at all.

At this point, not using swfobject is the only working solution I've come 
across.

Original comment by martins....@gmail.com on 9 Nov 2010 at 9:09

GoogleCodeExporter commented 9 years ago
Sorry to hear it. Unfortunately I don't have Lotus Notes, so I can't do any 
testing.

Walking through the logic:

* SWFObject 2's embedSWF() function writes <object> tags customized for the 
current browser (in your case IE).

* The main differences between the IE <object> element and non-IE <object> are 
the inclusion of the 'classid' attribute for IE and the use of the 'data' and 
'type' attributes for non-IE browsers.

<object id="flashcontent" 
        classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" 
        width="550px" 
        height="400px">
  <param name="movie" value="mymovie.swf" />

  <!--[if !IE]>-->
  <object type="application/x-shockwave-flash" 
          data="mymovie.swf" 
          width="550px" 
          height="400px">
  <!--<![endif]-->

  <!--[if !IE]>-->
  </object>
  <!--<![endif]-->

</object>

* You state that SWFObject's dynamically-generated <object> element is not 
working (or buggy) in the Lotus Notes browser (a derivative of IE).

* You also state that your hard-coded backup works fine.

So we must then look to see what the differences are between what embedSWF 
generates and your hard-coded backup:

1. You include the codebase attribute in your markup (SWFObject omits it)
2. You include an <embed> fallback, which is normally used by non-IE browsers.

Can you please test the following:

1. Perhaps Lotus Notes relies on codebase. Try removing the codebase attribute 
from your fallback markup and see if it makes a difference.

2. Perhaps Lotus Notes isn't using the <object> at all and is using the 
fallback <embed> element. Try removing the <embed> element (which shouldn't be 
needed in an IE environment, anyway) and see if it makes a difference.

If you discover the codebase attribute is needed by Lotus Notes, you can simply 
pass it to SWFObject as an attribute:

var isMSIE = /*@cc_on!@*/false; //see 
http://dean.edwards.name/weblog/2007/03/sniff/

var attributes = {};
if(isMSIE){
  attributes.codebase = "http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0";
}

swfobject.embedSWF("open-flash-chart.swf", "chartArea", "0", "0", "9.0.0", 
false, {}, {wmode: 'Transparent'}, attributes);

Original comment by platelu...@gmail.com on 9 Nov 2010 at 5:59

GoogleCodeExporter commented 9 years ago
1. "Perhaps Lotus Notes relies on codebase. Try removing the codebase attribute 
from your fallback markup and see if it makes a difference."

Removing "codebase" did not have any immediate effect.

2. "Perhaps Lotus Notes isn't using the <object> at all and is using the 
fallback <embed> element. Try removing the <embed> element (which shouldn't be 
needed in an IE environment, anyway) and see if it makes a difference."

Removing <embed> also did not cause any issues.

After removing everything I could, this is what I was left with:

<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" id="chartArea">
    <param name="movie" value="open-flash-chart.swf" />
</object>

a) When removing "classid" the empty chart object is not displayed, no error 
message, only an empty white square.

b) When removing param "movie", obviously, nothing is displayed.

c) Removing id="chartArea" caused the IO error to appear. 

I removed the CSS file and yet the chart was loaded, although no such 
#chartArea existed, meaning the presence of "id" itself was enough to satisfy 
the <object>.

Original comment by martins....@gmail.com on 10 Nov 2010 at 9:42

GoogleCodeExporter commented 9 years ago
Without the ID, ExternalInterface has no way to grab your object.

One thing to consider (though I doubt it will make a difference here) is your 
findSWF() function. The code you're using is what's provided in many 
ExternalInterface tutorials, but you can simply use 
document.getElementById(movieName). All major browsers support it.

function findSWF(movieName) {
   if (navigator.appName.indexOf("Microsoft")!= -1)
      return window[movieName];
   else
      return document[movieName];
}

This code should be all you need:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <link href="css/style.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="js/json2.js"></script>
    <script type="text/javascript" src="js/swfobject.js"></script>
    <title></title>
    <script type="text/javascript">
        var GLOBAL_CHART = {"elements": []};

        function ofc_ready(){
        }

        function open_flash_chart_data(){
            return JSON.stringify(GLOBAL_CHART);
        }

        function findSWF(movieName) {
            return document.getElementById(movieName);
        }

        swfobject.embedSWF("open-flash-chart.swf", "chartArea", "0", "0", "9.0.0","","", {wmode: 'Transparent'});
    </script>
    </head>
    <body>
        <div id="chartOne">
            <div id="secTitle"><span>SEC TITLE</span></div>
            <div id="chartArea">Adobe Flash is required to view the charts.</div>
        </div>
    </body>
</html>

Original comment by platelu...@gmail.com on 10 Nov 2010 at 5:43

GoogleCodeExporter commented 9 years ago
(but be sure to specify dimensions for the SWF or risk ExternalInterface 
failure)

Original comment by platelu...@gmail.com on 10 Nov 2010 at 5:44

GoogleCodeExporter commented 9 years ago
I did the changes you advised and yet I'm getting the IO Error.

This is the code (pretty much the same as the one you posted). I removed the 
css file and some other bits and pieces. Not much that could be removed at this 
point.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
    <script type="text/javascript" src="js/json2.js"></script>
    <script type="text/javascript" src="js/swfobject.js"></script>
        <title>Test</title>
    <script type="text/javascript">
        function ofc_ready(){
        }

        function open_flash_chart_data(){
        return JSON.stringify({"elements": []});
        }

        function findSWF(movieName) {
        return document.getElementById(movieName);
        }

        $(document).ready(function(){
        swfobject.embedSWF("open-flash-chart.swf", "chartArea", "500", "300", "9.0.0");
        });
    </script>
    </head>
    <body>
    <div>
        <div id="chartArea">Adobe Flash is required to view the charts.</div>
    </div>
    </body>
</html>

Original comment by martins....@gmail.com on 10 Nov 2010 at 6:31

GoogleCodeExporter commented 9 years ago
You don't need the jquery $(document).ready -- swfobject.embedSWF() has a 
built-in $(document).ready feature, so the jQuery becomes redundant.

Can you provide more specifics about the IO Error?  What error code are you 
getting? Is there any debug information available? Is the IO Error reported by 
Flash Player, IE, or your chart SWF?

Original comment by platelu...@gmail.com on 10 Nov 2010 at 7:39

GoogleCodeExporter commented 9 years ago
I removed the jQuery.

This is the Error I'm getting:

Open Flash Chart
IO ERROR
Loading test data
Error #2032

This is the URL that I tried to open:../../data-files/y-axis-auto-steps.txt

I can't debug it as Lotus doesn't have a JS console. Any suggestions?

Original comment by martins....@gmail.com on 11 Nov 2010 at 9:26

GoogleCodeExporter commented 9 years ago
Providing OFC2's "data-files" folder gets the chart to be displayed.

Original comment by martins....@gmail.com on 11 Nov 2010 at 9:40

GoogleCodeExporter commented 9 years ago
Google shows a ton of hits for:

Open Flash Chart
IO ERROR
Loading test data
Error #2032

So if the SWF loads the first time, as you stated in your first post, SWFObject 
is working (SWFObject merely embeds the SWF on the page). If subsequent 
refreshes cause issues, it could be a caching issue in the Lotus Notes browser 
(IE is notorious for caching issues). The SWFObject Google group has many tips 
for handling cache issues. 

http://groups.google.com/group/swfobject/search?group=swfobject&q=IE+cache&qt_g=
Search+this+group

Original comment by platelu...@gmail.com on 11 Nov 2010 at 9:29

GoogleCodeExporter commented 9 years ago
Thanks a lot for your help, hope this post is going to be of use to other 
developers.

Original comment by martins....@gmail.com on 11 Nov 2010 at 10:51