为什么不刷新Firefox反映javascript代码的变化?

时间:2012-02-08 13:17:53

标签: javascript firefox netbeans dojo

  

可能重复:
  Making sure a web page is not cached, across all browsers

我正在处理一个连接到dojo.store.Memory的简单dojo comboBox(dijit.form.ComboBox)。我使用最新的Netbeans和Glassfish设置,使用Firefox 10.我的问题是,当我更改或注释掉与组合框相关的代码时,更新不会在我刷新网页时显示。我已经尝试过清理/构建,重新运行等,但是注释掉代码似乎什么都不做。 Firefox似乎正在运行页面的缓存版本,而不是呈现我所做的最新代码更改。每次刷新页面时,我都不想清除浏览器缓存。 (我最终希望能够做的是在autoComplete打开和关闭时指示。)任何想法?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">                   
    <script src="http://ajax.googleapis.com/ajax/libs/dojo/1.7.1/dojo/dojo.js" type="text/javascript" ></script> 
 
    <script type="text/javascript">
        dojo.require("dijit.form.ComboBox");
        dojo.require("dojo.store.Memory");

        var myBox, store;
        dojo.ready(function(){makeComboBox();});

        function makeComboBox(){

            store = new dojo.store.Memory({
                data: [
                    {name:"Alabama", id:"AL"},
                    {name:"Alaska", id:"AK"},
                    {name:"American Samoa", id:"AS"},
                    {name:"Arizona", id:"AZ"},
                    {name:"Arkansas", id:"AR"},
                    {name:"Armed Forces Europe", id:"AE"},
                    {name:"Armed Forces Pacific", id:"AP"},
                    {name:"Armed Forces the Americas", id:"AA"},
                    {name:"California", id:"CA"},
                    {name:"Colorado", id:"CO"},
                    {name:"Connecticut", id:"CT"},
                    {name:"Delaware", id:"DE"}                        
                ]
            });                

            myBox = new dijit.form.ComboBox({                
                id: "stateSelect",
                name: "state",
                //value: "Alabama", 
                //store: store,  <-- the box is still connected to the store, 
                                 <--even if I comment it out
                searchAttr:"name"
            }, "stateSelect");
            //myBox.set("autoComplete", "false"); <-- this doesn't work either
        }
    </script>

<div id="myDiv"  >
    <input id="stateSelect" >
    <p><button onClick="alert(dijit.byId('stateSelect').get('value'))">get value</button></p>
</div>

1 个答案:

答案 0 :(得分:4)

对于速度,FireFox会缓存页面和外部文件。要刷新并阻止从缓存中拉出页面,请按 Ctrl + F5

有关详情,请参阅this question