简体   繁体   English

为什么ASP.NET(3.5)始终不加载外部javascript?

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

I have an external JavaScript in an asp.net 3.5 project. 我在asp.net 3.5项目中有一个外部JavaScript。 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. 在编写不同的函数时,有时将JavaScript加载到FF中,有时却未加载(基于FireBug),并且JavaScript无法运行。 Even if there is an error in the JS it should still load or be visible to the browser, right? 即使JS中有错误,它仍应加载或对浏览器可见,对吗?

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: 母版页从项目中的脚本目录加载JS:

<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 -->
       <script src="Scripts/JScript.js" type="text/javascript"></script>    
</head>  

JScript.js 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);


 }    

如果运行,即使未加载,也很可能是因为使用了缓存版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM