开发者

Why doesn't ASP.NET (3.5) always load an external javascript?

I have an external JavaScript in an asp.net 3.5 project. While writing different functions, sometimes the JavaScript is loaded into FF and sometimes it is not (based on FireBug) and the JavaScript does not run. Even if there is an error in the JS it should still load or be visible to the browser, right?

What is the logic behind when it is loaded and when it doesn't load (or is accessible to the browser?)

EDIT

Master Page loads JS from a script directory in project:

<head runat="server">

    <asp:ContentPlaceHolder id="head" runat="server">
    </asp:ContentPlaceHolder>
     <!-- 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 -->
       &开发者_如何学Clt;script src="Scripts/JScript.js" type="text/javascript"></script>    
</head>  

JScript.js

//Load google api
 google.load('visualization', '1', {packages:['gauge']});
 google.setOnLoadCallback(update);




 function update(x) {

 var test = parseInt(x.value);    

 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, 0);
 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
 };

 //smooth transition to new value, need to implement "from" value.
 setTimeout(function() { data.setValue(0, 1, test); chart.draw(data, options); }, 0);


 chart.draw(data, options);


 }    


If it runs, even when it's not loaded, that's most probably because a cached version is used.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜