views:

23

answers:

2

I used an example script of how to load an SWF file with the JQuery SWF plugin (http://jquery.thewikies.com/swfobject/examples). I am trying to get the plugin to work in a JSP. It appears to work in FireFox and Chrome but not in IE8.

Can anyone see any obvious issues? Thanks in advance.


<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml"&gt;
<head>
   <script type="text/javascript" src="js/jquery-1.4.2.js"></script>
</head>
<script type="text/javascript" src="js/jquery.swfobject.1-1-1.js"></script>
<body>
<script type="text/javascript">

var bar_chart = $.flash.create (
    {
        swf: 'flash/open-flash-chart.swf',
           width: 350,
           height: 260,
           wmode: 'transparent',
           play: true,
           flashvars: {
              "get-data": "getChart1Data"
           }
    }
);

function getChart1Data()
{
    return JSON.stringify(${chart1Data});
};

function ofc_ready()
{ 
    /**/ 
};

$(document).ready(
    function() {
         $('#bar_chart').html(bar_chart);
    }
);
</script>

<tr>
  <td colspan="2">
    <table>
      <tr>
        <td>
          <div id="bar_chart"></div>
        </td>
      </tr>
    </table>
  </td>
 </tr>
</body>
</html>
A: 

All you have to do is change your swfobject version to latest SWFObject 2.2

<script type="text/javascript" src="js/jquery.swfobject.1-1-1.js"></script>

This will fix ie issue

try

flashMovie = null;

$(document).ready(
    function () {
        flashMovie = $('#bar_chart');
        flashMovie.flash(
            {
        swf: 'flash/open-flash-chart.swf',
        width: 350,
        height: 260,
        wmode: 'transparent',
        play: true,
        flashvars: { "get-data": "getChart1Data" }
            }
        );
    }
);

function getChart1Data() { return JSON.stringify(${chart1Data}); };
JapanPro
Works like a charm, thanks
Andrew Jones
accept as an answer if so :)
JapanPro
+2  A: 

Your HTML is syntactically invalid. The browser behaviour is unpredictable.

This one is syntactically valid. Give it a try.

<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<!DOCTYPE html>
<html>
    <head>
        <title>Insert your title</title>
        <script type="text/javascript" src="js/jquery-1.4.2.js"></script>
        <script type="text/javascript" src="js/jquery.swfobject.1-1-1.js"></script>
        <script type="text/javascript">
            var bar_chart = $.flash.create ({
                swf: 'flash/open-flash-chart.swf',
                width: 350,
                height: 260,
                wmode: 'transparent',
                play: true,
                flashvars: {
                    "get-data": "getChart1Data"
                }
            });

            function getChart1Data() {
                return JSON.stringify(${chart1Data});
            }

            function ofc_ready() { 
                /**/ 
            }

            $(document).ready(function() {
                $('#bar_chart').html(bar_chart);
            });
        </script>
    </head>
    <body>
        <div id="bar_chart"></div>
    </body>
</html>

PS: I removed the table since it's incomplete and only adds noise to the demo.

BalusC
You are a genius. T'worked.
Andrew Jones
You're a genius - it worked! - Thanks a bill.
Andrew Jones
You're welcome. Don't forget to mark the most helpful answer on your questions accepted. See also http://stackoverflow.com/faq.
BalusC