为什么Google可视化会导致HTML1504意外的结束标记错误

为什么Google可视化会导致HTML1504意外的结束标记错误

本文介绍了为什么Google可视化会导致HTML1504意外的结束标记错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

任何人都可以解释为什么当使用Google Visualization API显示图表时,为什么会出现 HTML1504:意外结束标记警告?

我一直在调试Firefox中图表显示正常的网站,但没有在IE11中显示任何数据。我最终解决了这个问题(IE11处理的日期格式与Firefox不同),但浪费了大量时间来追踪上述错误。



我的代码是根据,它提供了相同的信息。如果我注释掉 google.load('visualization(可视化))行,警告就消失了。 ','1.0',{'packages':['corechart']}); 但这显然会阻止图表工作。更改IE11兼容性设置似乎没有任何效果。



该错误在IE11 Developer Console中可见,但在控制台,浏览器控制台或Firefox中的Firebug控制台。 IE11报告错误是由我的图表代码(这是嵌入式JavaScript,而不是单独的文件)结尾处的< / script> 标记触发的。删除< / script> 标记会导致HTML错误(如预期的那样!)

我很感兴趣,在Javascript中调用应该能够导致周围的HTML错误。警告信息是否重要?可以避免吗?

解决方案

我在MS Edge + Win 10上遇到同样的问题。 / p>

 <!DOCTYPE html>< html>< head> 
< script type =text / javascriptsrc =https://www.gstatic.com/charts/loader.js>< / script>
< script type =text / javascript>
google.charts.load('current',{'packages':['corechart']});
< / script>
< / head>
< body>< / body>
< / html>

加载了jsapi的Google图表不再更新,除非绝对必要。


Can anyone explain why I get a HTML1504: Unexpected end tag warning when using the Google Visualization API to display a chart?

I have been debugging a website where the chart displayed fine in Firefox, but didn't show any data in IE11. I eventually fixed the problem (an invalid date format that IE11 handled differently to Firefox), but wasted a lot of time trying to track down the above error.

My code is based on the example code at https://developers.google.com/chart/interactive/docs/quick_start, which gives the same message. Nothing untoward shows up in either JSLint or the W3C HTML Validator.

The warning goes away if I comment out the line google.load('visualization', '1.0', {'packages':['corechart']}); but this obviously stops the chart working too. Changing the IE11 compatibility settings did not appear to have any effect.

The error is visible in the IE11 Developer Console, but nothing equivalent comes up in the Console, Browser Console or Firebug console in Firefox. IE11 reports the error as being triggered by the </script> tag at the end of my chart code (this is inline javascript, rather than a separate file). Removing the </script> tag causes HTML errors (as expected!)

I am intrigued that a function call in Javascript should be able to cause an error in the surrounding HTML. Is the warning message significant? Can it be avoided?

解决方案

I had the same issue on MS Edge + Win 10. No warnings with the new loader:

<!DOCTYPE html><html><head>
  <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
  <script type="text/javascript">
    google.charts.load('current', {'packages':['corechart']});
  </script>
</head>
<body></body>
</html>

Google charts that are loaded with jsapi, are no longer updated unless absolutely necessary.

这篇关于为什么Google可视化会导致HTML1504意外的结束标记错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-07 01:03