JavaScript

  • 94
  • 0
  • 2017-11-28

使用者,無須關閉瀏覽器,開啟無痕模式去刪除,瀏覽器Cookie,enter or F5 reload 及更新的Javascript的寫法。 

(1)純JavaScript 
<script>document.write("<script type='text/javascript' src='Scripts/myJavascript.js?v=" + Date.now() + "'><\/script>");</script>

缺點:絕對路徑

---------------------------------------------------------------------------------

(2)MVC View Razor
<script src='~/Scripts/myJavascript.js?v=@DateTime.Now.Millisecond' type='text/javascript'></script>

優點:相對路徑

(3)PHP
<script type="text/javascript" src="myJavascript.js?_dt=<=time();?>"></script>


---------------------------------------------------------------------------------

myJavascript.js => 要匯入的JS

---------------------------------------------------------------------------------




絕對路徑與相對路徑差別:

http://www.jianshu.com/p/f84bce255bb0