开发者

how to resize a div as soon as the document is loaded

i am trying to do this in javascript:

  var w = 1280;
  var h = 1024;
  window.onload = function()
  {
    if (w > 0)
      document.getElementById('flashdiv').style.width=w;
    else
      document.getElementById('flashdiv').style.width="100%";


   alert(document.getElementById('flashdiv').style.width);

    if (h > 0)
      document.getElementById('flashdiv').style.height=h;
    else
      document.getElementById('flashdiv').style.height="100%";
  };开发者_如何转开发

but it doesnt seem to resize the div at all. what am i missing here?


style.width is a string so you have to do

document.getElementById('flashdiv').style.width=w+"px";
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜