window.onload和$(document).read()

用$(document).read()中获取页面高度时,往往有些不准,可以试下window.onload

window.onload = function(){
	setTimeout(function(){
		var h = document.body.offsetHeight;
		$("#dataadmin").attr('src',"http://data.admin.t.sina.com.cn/setheight.php?h="+h);
	},1000);
};

 

setTimeout是因为页面图表中延迟加载的情况!所以获取的高度需要延迟加载!

你可能感兴趣的:(function,document,职场,休闲)