標籤:c style http a width strong
在有了這個
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">標記的時候,說明這裡引用的JS以及CSS都要符合編碼規範,有些JS編寫不符合規範,可能會導致
無法正常運行。
解決這個問題的方法:這是因為加入DOCTYPE申明後,js裡是不能使用document.body的,一定要改成document.documentElement,還有就是加"px"。
修改前:...width = document.body.clientWidth;height = document.body.clientHeight;Hoffset = img1.offsetHeight;Woffset = img1.offsetWidth;img1.style.left = xPos + document.body.scrollLeft;img1.style.top = yPos + document.body.scrollTop;...修改後:...width = document.documentElement.clientWidth;height = document.documentElement.clientHeight;Hoffset = qingrenjie_pd.offsetHeight;Woffset = qingrenjie_pd.offsetWidth;img1.style.left = xPos + document.documentElement.scrollLeft + "px";img1..style.top = yPos + document.documentElement.scrollTop + "px";