Where does Google keep this file used for Google V

2020-06-27 00:45发布

问题:

EDIT
Please see the produced html and Javascript here:
http://jsfiddle.net/GregMcNulty/K6Vrb/1/

According to this Comment 4 - the comment at the beginning of the file is causing issues.

My question is, which file is this and when does it get loaded?

The only file I load is: https://www.google.com/jsapi as shown in the example.

So if I can figure out when and how it is called, can I make this a local file on my site instead of calling it from google.... and edit it to remove the comments, so i can get the google gauges to work in IE?

Thanks.

Not sure why putting the meta data in the head is not working for me either? Should that work in all cases?

Anyone have a specific example they can show how they got the google visualization/charts working with IE?

The head without any doc type, however, it renders the rest of the body (not shown) terribly...

<html>
<head><meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />  
<title>
    Your Levels
</title>

     <!-- Google JavaScript for gauges -->
       <script src='http://www.google.com/jsapi' type='text/javascript' ></script>   
    <!-- Style Sheet -->
       <link href="Styles/EliteCircle.css" rel="stylesheet" type="text/css" />    
    <!-- My local JavaScript File -->
       <script src="Scripts/JScript.js" type="text/javascript"></script>



</head>


<body>

    <form name="aspnetForm" method="post" action="Stats.aspx" onsubmit="javascript:return WebForm_OnSubmit();" id="aspnetForm">  

...etc...

回答1:

The solution is easy.

The DOCTYPE in the comment is the DOCTYPE in your web page. The one that calls the Google Visualization javascript.

Proof:

  1. Take the Gauge example on the Google Visualization page.
  2. Cut and paste it in a file g.html on your desktop
  3. do not add any DTD <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> on top of the HTML tag.
  4. Open it in IE8 => works
  5. add the DTD shown in 3 => broken.

So basically, to make it work, in IE8, omit the DTD before the html opening tag.

I've tried other DTDs, especially the xhtml 1 strict, known to make IE behave. No luck yet.

Update

By the way, when I add the dtd inserted by visual studio (antique 4.01) it still works. I've also added your header. The file below works fine in IE8 for me.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<title>
    Your Levels
</title>
     <!-- Style Sheet -->
       <link href="Styles/EliteCircle.css" rel="stylesheet" type="text/css" />    
    <!-- My local JavaScript File -->
       <script src="Scripts/JScript.js" type="text/javascript"></script>
    <script type='text/javascript' src='https://www.google.com/jsapi'></script>
    <script type='text/javascript'>
        google.load('visualization', '1', { packages: ['gauge'] });
        google.setOnLoadCallback(drawChart);
        function drawChart() {
            var data = new google.visualization.DataTable();
            data.addColumn('string', 'Label');
            data.addColumn('number', 'Value');
            data.addRows(3);
            data.setValue(0, 0, 'Memory');
            data.setValue(0, 1, 80);
            data.setValue(1, 0, 'CPU');
            data.setValue(1, 1, 55);
            data.setValue(2, 0, 'Network');
            data.setValue(2, 1, 68);

            var chart = new google.visualization.Gauge(document.getElementById('chart_div'));
            var options = { width: 400, height: 120, redFrom: 90, redTo: 100,
                yellowFrom: 75, yellowTo: 90, minorTicks: 5
            };
            chart.draw(data, options);
        }
    </script>
  </head>
  <body>
    <div id='chart_div'></div>
       <form name="aspnetForm" method="post" action="Stats.aspx" onsubmit="javascript:return WebForm_OnSubmit();" id="aspnetForm">  
       </form>
  </body>
</html>