javascript – 将HTML链接添加到Google Charts表

前端之家收集整理的这篇文章主要介绍了javascript – 将HTML链接添加到Google Charts表前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试将 HTML链接添加到Google Chart Table列.对于列和表,我有setHTML:true,但它只是显示HTML代码而不是解释它.有人能指出我正确的方向吗?

谢谢

<!--
You are free to copy and use this sample in accordance with the terms of the
Apache license (http://www.apache.org/licenses/LICENSE-2.0.html)
-->

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <Meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <title>
      Google Visualization API Sample
    </title>
    <script type="text/javascript" src="http://www.google.com/jsapi"></script>
    <script type="text/javascript">
      google.load('visualization','1',{packages: ['table']});
    </script>
    <script type="text/javascript">

     function drawVisualization() {
      // Create and populate the data table.
      var data = google.visualization.arrayToDataTable([
        ['Name','Logged In'],['<a href="LINK">Item 1</a>','Item 2'],]);

       data.setColumnProperty(0,{allowHTML: true});
   // Create and draw the visualization.
   visualization = new google.visualization.Table(document.getElementById('table'));
       visualization.draw(data,{allowHTML: true});
    }

   google.setOnLoadCallback(drawVisualization);
    </script>
  </head>
  <body style="font-family: Arial;border: 0 none;">
    <div id="table"></div>
  </body>
</html>
​

解决方法

allowHTML属性区分大小写.它必须是{allowHtml:true}.

猜你在找的JavaScript相关文章