atorres

Javascript error in IE8 (SetReturnValue method)

Recommended Posts

Hello,

 

I am testing IE8 and it is showing the following error:

 

"Microsoft JScript runtime error: Object doesn't support this property or method"

 

when executing this code:

 


try 

{ 

   document.getElementById("graficoCotacoes").SetReturnValue(__flash__toXML(FC_Loaded("graficoCotacoes")) );

} catch (e) 

{ 

   document.getElementById("graficoCotacoes").SetReturnValue("");

}

 

I have debugged the javascript code in FusionCharts.js and on line #255 and noticed that on the "if" condition, the instruction

document.embeds[this.getAttribute('id')]

returns 'undefined' and immediately after, the exception is thrown!!!

 

At the time i wasn

Share this post


Link to post
Share on other sites

I am having the same problem, My code works in Chrome and FF but throws an error in IE.

 

 

 

This is the error I am getting:

 

Line: 1

Error: Object doesn't support this property or method

 

When I debug with IE i find the error is on this line.

 

try { document.getElementById("mainChart").SetReturnValue(__flash__toXML(FC_Loaded("mainChart")) ); } catch (e) { document.getElementById("mainChart").SetReturnValue(""); }

 

 

 

I attached my source code perhaps someone can tell me if I'm doing something obviously wrong.

 

 

 


 

< !doctype html>

 

< html xmlns=" http://www.w3.org/1999/xhtml" >

 

< head>

 

< title> Test< /title>

 

< script SRC=" /js/fusionCharts/FusionCharts.js" type=" text/javascript" > < /script>

 

< script SRC=" /js/fusionCharts/FusionChartsExportComponent.js" type=" text/javascript" > < /script>

 

 

 

< /head>

 

< body>

 

 

 

< a class=" button" href=" javascript:void(0);" onclick=" initiateExport();" > Export/Print Chart< /a>

 

< br />

 

< div id=" mainChart" style=" " > The chart will appear within this DIV. This text will be replaced by the chart.< /div>

 

< script type=" text/javascript" >

 

var myChart = new FusionCharts(" /charts/FusionCharts/Column3D.swf" , " mainChart" , " 900" , " 300" , " 0" , " 1" );

 

myChart.setDataXML(" < chart exportEnabled='1'exportShowMenuItem='1'exportAtClient='1' exportHandler='fcExporter1' exportFileName='MyFile' showAboutMenuItem='0' showExportDataMenuItem='1' caption='Monthly Sales Summary' subcaption='For the year 2006' xAxisName='Month' yAxisName='Sales' numberPrefix='$'> < set label='January' value='17400' /> < set label='February' value='19800' /> < set label='March' value='21800' /> < set label='April' value='23800' /> < set label='May' value='29600' /> < set label='June' value='27600' /> < set label='July' value='31800' /> < set label='August' value='39700' /> < set label='September' value='37800' /> < set label='October' value='21900' /> < set label='November' value='32900' /> < set label='December' value='39800' /> < /chart> " );

 

myChart.render(" mainChart" );

 

< /script>

 

< div style=" float:left" id='handlerDivWrapper'>

 

< div id='exportHandlerDiv'> FusionCharts Export Handler Component< /div>

 

< /div>

 

< script type=" text/javascript" >

 

var fcExportComponent = new FusionChartsExportObject('fcExporter1', '/charts/FusionCharts/FCExporter.swf');

 

fcExportComponent.sourceCharts = " ['mainChart']" ;

 

//Full Mode

 

fcExportComponent.componentAttributes.fullMode = '1';

 

//Set saving type to individual

 

fcExportComponent.componentAttributes.saveMode = 'both';

 

//Show allowed export format drop-down

 

fcExportComponent.componentAttributes.showAllowedTypes = '1';

 

//Width and height

 

fcExportComponent.componentAttributes.width = '350';

 

fcExportComponent.componentAttributes.height = '250';

 

//Message - caption of export component

 

fcExportComponent.componentAttributes.showMessage = '1';

 

fcExportComponent.componentAttributes.defaultExportFileName = " my_file" ;

 

fcExportComponent.componentAttributes.message = 'Save file(s) in desired format, then open file to print or attach to email.';

 

//Render the exporter SWF in our DIV fcexpDiv

 

fcExportComponent.Render(" exportHandlerDiv" );

 

function initiateExport(){

 

fcExportComponent.BeginExportAll();

 

}

 

< /script>

 

< /body>

 

< /html>

 

 

 

 

By the way SANATIZE YOUR FORM INPUTS It makes me sick that i had to html encode my source just to post on your site...

Edited by Guest

Share this post


Link to post
Share on other sites

I figured out the problem...

 

I basically make sure the div that the javascript is being injected into does not have the same id as the chartId otherwise IE will throw an error.

Share this post


Link to post
Share on other sites

By the way I also recommend adding

 

 

 

//Add wmode transparency to allow overlay

this.addParam('wmode', 'opaque');

 

 

 

to the FusionCharts.js file provided by FC to allow for overlaying any html you may want on top of the chart.

Share this post


Link to post
Share on other sites

The example is very good I used it and created a html link and when i click on it the export is starting

I dont know how to manage to export type (pdf/jpg) is there a way to configure it ?

also after the export finished how can i invoke the save action ?

 

my goal is to export and save in one click instead of one click for export and another for save

 

appreciate your help

Share this post


Link to post
Share on other sites
Guest Sashibhusan

Hi,

 

With regard to your query, please note that right now FusionCharts does not have the feature of saving the chart image without clicking the "save" button, for Flash Charts.

 

However you can trigger the capture process automatically immediate after chart renders in browser, by using FusionCharts JavaScript API function "exportChart();".

 

Ref. Code:

myChart.addEventListener( "rendered" , function ()  { FusionCharts("myChartId").exportChart( { exportAtClient: '0',  exportFormat: 'JPG' } ); 

 

Otherwise you can use JavaScript charts for exporting, in which you can export and save the chart in one click.

 

To see the example of "Exporting JavaScript Charts at client side", please follow the link below:

http://docs.fusionch...criptChart.html

 

Hope this helps!

Edited by Sashibhusan

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now