繁体   English   中英

更新初始screenWidth值,而无需刷新页面

[英]update the initial screenWidth value without having to refresh the page

我有以下javascript代码:

var screenWidth = {"width": document.documentElement.clientWidth}
d3.select(window).on('resize', resize)
function resize() {
    var clientWidth = document.documentElement.clientWidth
    screenWidth["width"] = clientWidth
    return clientWidth
}

我正在使用D3.js库

每次屏幕大小更改时,函数resize都会返回clientWidth,但是在不刷新页面的情况下更新初始screenWidth值的正确方法是什么?

把它放在你身体的尽头:

(function() {
   // your page initialization code here
   // the DOM will be available here
    var windowWidth = resize();
})();

暂无
暂无

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

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