再追问两个问题,js有办法得到一个没有设置height和width的元素的大小么?
还有,有什么办法可以把网页的一个div内的元素截图出来么?或者要套到一个iframe里面?
有答分会大大加的。先谢过各位!

解决方案 »

  1.   


    <input type="button" onclick="alert(document.getElementsByName('radio')[2].checked)" value="test1" />
    <input type="radio" name="radio" id="radio" value="radio" />
    <input type="radio" name="radio" id="radio" value="radio" />
    <input type="radio" name="radio" id="radio" value="radio" />
    <hr />
    <input type="button" onclick="alert(document.images[0].width+'*'+document.images[0].height)" value="test2" />
    <img src="http://i3.sinaimg.cn/home/deco/2008/0325/sinahome_Logo.gif" />
    <hr />
    <input type="button" onclick="frames[0].document.body.innerHTML=document.getElementById('div1').innerHTML;" value="test3" />
    <div id="div1">Text<img src="http://i3.sinaimg.cn/home/deco/2008/0325/sinahome_Logo.gif" /><button onclick="alert('嗯')">按钮</button></div>
    <iframe width="320px" height="240"></iframe>
      

  2.   

    clientHeight   获取对象的高度,不计算任何边距、边框、滚动条,但包括该对象的补白。
    clientWidth   获取对象的宽度,不计算任何边距、边框、滚动条,但包括该对象的补白。此外,还有一些其它类型的获取方法,可以查查手册。
      

  3.   

    回3楼:
    第一个问题是从一组已经check了的单选组,现在要找出那个被选中的对象的value;
    第二个问题是在没有给对象定义height和width的情况下,这样如果按你的方法是取undefined;
    第三个问题恕我没有表达清楚,我是主要是要截取一个div中元素转换为图片,iframe只是我曾经看到的一种方法,好象可以把里面的元素变成一个图片。
      

  4.   

    回4楼:
    innerHeight, innerWidthRead-only properties that specify the height and width, in pixels, of the document display area of this window. These dimensions do not include the size of the menu bar, toolbars, scrollbars, and so on. These properties are not supported by IE. Instead use the clientWidth and clientHeight properties of document.documentElement or document.body (depending on the version of IE). 这是javascript 权威指南里面的,这两个值貌似返回的是浏览区域的高和宽。
      

  5.   

    再回4楼你说的应该是offsetHeight和offsetWidth吧,嘿嘿,多谢提示。其他问题好像暂时没有最满意答案,多谢各位,结贴了