首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

swfupload 源码翻阅笔记四

2012-10-24 
swfupload 源码阅读笔记四// Update the flash url if neededif (!!this.settings.prevent_swf_caching) {

swfupload 源码阅读笔记四

        // Update the flash url if needed        if (!!this.settings.prevent_swf_caching) {                this.settings.flash_url = this.settings.flash_url + (this.settings.flash_url.indexOf("?") < 0 ? "?" : "&") + "preventswfcaching=" + new Date().getTime();        }

?

双叹号号称可以把任何类型转换成 bool 类型,但是不能隐式转换么?

?

下面的讨论里指出,这是一种让人费解而模糊的写法,强烈不推荐

http://stackoverflow.com/questions/784929/what-is-the-operator-in-javascript

?

?

//Maximum Obscurity:val.enabled = !!userId;//Partial Obscurity:val.enabled = (userId != 0) ? true : false;//And finally, much easier to understand:val.enabled = userId != 0;
?

重点来了,这里主要是为了防止 flash 被缓存,处理方法是在资源的 url 请求链接里添加一个时间参数以使每次都去下载,而不利用本地缓冲的。实际上 css, javascript 也都可以采用这种方法,但是有一种更加合理的方式是,将资源修改的时间或者版本号加在 url 里。这样就不会每次都下载了,只在变化时下载。

?

热点排行