在IE8的下一行没有找到HighChart'tooltip'对象 [英] HighChart 'tooltip' object is not found on the very next line in IE8

查看:88
本文介绍了在IE8的下一行没有找到HighChart'tooltip'对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用HighCharts和JQuery(ASP.Net,C#,MVC)在我的网页上显示图表。我已经使用下面的代码在页面加载时最初显示工具提示。还可以在鼠标移出图表区域时保留工具提示和十字准线。感谢@ jugal-thakkar的回答

  chart = new Highcharts.Chart({
...< my图表选项在这里>
...
});

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

引用我以前的帖子这里,我面临着IE8浏览器的问题。第一次加载页面时找不到工具提示对象。然后刷新页面后,它开始正常工作。



我在这里错过任何IE8修复程序吗?想知道为什么它没有在第一时间找到tooltip对象!



这里是IE8上F12的控制台登录:

 'tooltip'为空或不是对象


解决方案

工具提示对象在 document.onreadystatechange 被激发时状态为完成

如果您将以下内容添加到您的代码中,那么它应该推迟尝试提示工具提示,直到它被创建为止。

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


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

解决方案

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 () { };
    }
});

这篇关于在IE8的下一行没有找到HighChart'tooltip'对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆