HighChart 'tooltip' object is not found on the very next line in IE8

一个人想着一个人 提交于 2019-12-13 04:47:05

问题


I am using HighCharts with JQuery (ASP.Net, C#, MVC) to show chart on my web page. I have used below code to display the tooltip initially when page loads. Also to keep the tooltip and crosshair when mouse moves out of chart area. Thanks to answer by @jugal-thakkar

chart = new Highcharts.Chart({
... <my chart options go here>
...
});

...
chart.tooltip.refresh([chart.series[0].points[1]]);
chart.tooltip.hide = function () { };
chart.tooltip.hideCrosshairs = function () { };

Referring to my earlier post Here, I am facing problem with IE8 browser. The tooltip object is not found when I load the page first time. Then after refreshing the page, it starts working fine.

Am I missing any IE8 fix here? Wondering why it does not find the tooltip object only at first time!

Here is the Console Log in F12 on IE8:

'tooltip' is null or not an object

回答1:


The tooltip object is not instantiated until the document.onreadystatechange is fired with a state of complete.

If you add the following to your code then it should defer attempting to raise the tooltip until it has been created

document.attachEvent('onreadystatechange', function () {
    if (document.readyState === 'complete') {
        chart.tooltip.refresh([chart.series[0].points[1]]);
        chart.tooltip.hide = function () { };
        chart.tooltip.hideCrosshairs = function () { };
    }
});


来源:https://stackoverflow.com/questions/12383156/highchart-tooltip-object-is-not-found-on-the-very-next-line-in-ie8

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!