开发者

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

开发者 https://www.devze.com 2023-02-08 02:18 出处:网络
i am trying to do this in javascript: var w = 1280; var h = 1024; window.onload = function() { if (w > 0)

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

精彩评论

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