0
我正在嘗試製作旗幟。該橫幅用寬度和高度的百分比製成。當身體被裝載時,它應該在所有分辨率下看起來不錯。但是,我的代碼似乎不工作。如果任何人都可以看看它,將不勝感激。加載旗幟高度和寬度
<script>
function load()
{
document.write("Available Width: " + Math.round((screen.availWidth)/5));
a=document.getElementById('banner');
a.style.width=Math.round((screen.availWidth));
a.style.height=Math.round((screen.availHeight)/5);
}
</script>
我將它改爲\t a.style.width = Math.round((screen.availWidth))+'px'; \t \t但它似乎仍然不工作 –
那麼,在這種情況下,你是否在DOM樹中存在'id =「banner」'元素時調用函數?另外嘗試刪除'document.write'行。 –