请问用js 怎么控制一个标签下(如TD)遍历所有图片 控制其显示高度和宽度 这种问题都没有知道吗?????不知道的大家探讨一下也好啊! 好难哦 枚举html标签 我一点不会 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <body><table><tr><td id="otd"><div></div><img/><img/><hr/><img/></td></tr></table><script language="JavaScript" type="text/javascript">function set(){ var o = document.getElementById("otd"); var cns = o.childNodes; for(var i=0;i<cns.length;i++) { var __temp = cns[i]; if(__temp.tagName.toLowerCase() == "img") { __temp.width = 40; __temp.height = 40; } }}set();</script></body> <!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"><!-- DW6 --><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>shawl.qiu template</title><style type="text/css">/* <![CDATA[ *//* ]]> */</style><script type="text/javascript">//<![CDATA[window.onload=function(){ fResizeImg(400, 300, 'table'); //fResizeImg(500, 500);} /*------------------------------------------------------*\ * Subject: 使用 javascript 函数 完美控制页面图片显示大小 By shawl.qiu * 使用: * -------------------------------------- * 1. Javascript 脚本块 * window.onload=function(){ * fResizeImg(500, 500, 'img'); * //fResizeImg(500, 500); * } * * 2. html body 标签 * <body onload="fResizeImg(500, 500, 'textMain');" > * -------------------------------------- * 注: 必须在页面加载完毕后使用本函数(这是基本的客户端应用概念) \*-------------------------------------------------------*/ //---------------------------------begin function fResizeImg(); function fResizeImg(w, h, id){ var img=''; var obj; if(id==undefined)obj=document.images; else obj=document.getElementById(id).getElementsByTagName('img'); for(var i=0; i<obj.length; i++){ img=obj[i]; if(img.width>w&&(img.height<img.width)){ img.height=img.height-(img.height/(img.width/(img.width-w))) img.width=w; }else if(img.height>h&&(img.height>img.width)){ img.width=img.width-(img.width/(img.height/(img.height-h))) img.height=h; } img.onclick=function(){ try{ imgPopup.close();} catch(e){} imgPopup=open('#', 'imgurl', 'width=500, height=500, left='+(screen.availWidth-500)/2+ ', top='+(screen.availHeight-500)/2) imgPopup.document.write('<script>document.onclick=function(){ close();} /* 单击关闭窗口 */ <\/script>'); imgPopup.document.write('<img src="'+this.src+'"/>'+ '<script>'+ 'var w, h;'+ 'var img=document.images[0];'+ 'if(navigator.appName=="Opera"){w=img.width+10; h=img.height+40} else {w=img.width+10; h=img.height+25};'+ 'self.resizeTo(w, h);'+ 'self.moveTo((screen.availWidth-img.width)/2,(screen.availHeight-img.height)/2)'+ '<\/script>'+ '<style>body{margin:0; padding:0;} .hd{visibility:hidden;}<\/style>'); imgPopup.document.write('<p class="hd">ok</p>'); imgPopup.document.close(); imgPopup.focus(); } } // shawl.qiu script } //---------------------------------end function fResizeImg();//]]></script></head><body><table width="100%" border="1" id="table"> <tr> <td><img src="temp/2006-10-15/01.jpg" width="400" height="381" /></td> <td><img src="mod/system/themes/default/default/images/gi_logo_88_31.png" width="88" height="31" /><img src="images/04.jpg" width="640" height="467" /></td> <td><img src="mod/system/themes/default/default/images/gi_logo_88_31.png" width="88" height="31" /></td> </tr> <tr> <td><img src="mod/managemain/themes/default/default/images/gi_logo_300_92.png" width="300" height="92" /></td> <td><img src="images/03_1.jpg" width="832" height="1126" /></td> <td><img src="images/gi_logo_300_92.png" width="300" height="92" /></td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr></table></body></html> 关于Ext框架使用 JS中多个setInterval同时运行100个function还是单个setInterval运行100个funtion,哪个效率更高 jquery append 在ie8中问题 打开对话框后,焦点问题 请教一个输入框计算的问题 不知道什么原因js弹框不显示e-mail内容!求大神指点 任务栏的高度 js中如何在浏览器里传递变量 大哥们帮我看看!!!在线等!!!!!eval报错 关于array[i]和array.item(i)的问题 是否能动态的在一个固定图片上加上文字..请大大们指教 这样写,取得Frame里面的值有错,帮忙看看
<table><tr><td id="otd"><div></div><img/><img/><hr/><img/></td></tr></table>
<script language="JavaScript" type="text/javascript">
function set()
{
var o = document.getElementById("otd");
var cns = o.childNodes;
for(var i=0;i<cns.length;i++)
{
var __temp = cns[i];
if(__temp.tagName.toLowerCase() == "img")
{
__temp.width = 40;
__temp.height = 40;
}
}
}
set();
</script>
</body>
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- DW6 -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>shawl.qiu template</title>
<style type="text/css">
/* <![CDATA[ *//* ]]> */
</style>
<script type="text/javascript">
//<![CDATA[
window.onload=function(){
fResizeImg(400, 300, 'table');
//fResizeImg(500, 500);
}
/*------------------------------------------------------*\
* Subject: 使用 javascript 函数 完美控制页面图片显示大小 By shawl.qiu
* 使用:
* --------------------------------------
* 1. Javascript 脚本块
* window.onload=function(){
* fResizeImg(500, 500, 'img');
* //fResizeImg(500, 500);
* }
*
* 2. html body 标签
* <body onload="fResizeImg(500, 500, 'textMain');" >
* --------------------------------------
* 注: 必须在页面加载完毕后使用本函数(这是基本的客户端应用概念)
\*-------------------------------------------------------*/
//---------------------------------begin function fResizeImg();
function fResizeImg(w, h, id){
var img='';
var obj;
if(id==undefined)obj=document.images;
else obj=document.getElementById(id).getElementsByTagName('img');
for(var i=0; i<obj.length; i++){
img=obj[i];
if(img.width>w&&(img.height<img.width)){
img.height=img.height-(img.height/(img.width/(img.width-w)))
img.width=w;
}else if(img.height>h&&(img.height>img.width)){
img.width=img.width-(img.width/(img.height/(img.height-h)))
img.height=h;
}
img.onclick=function(){
try{ imgPopup.close();} catch(e){}
imgPopup=open('#', 'imgurl', 'width=500, height=500, left='+(screen.availWidth-500)/2+
', top='+(screen.availHeight-500)/2)
imgPopup.document.write('<script>document.onclick=function(){ close();} /* 单击关闭窗口 */ <\/script>');
imgPopup.document.write('<img src="'+this.src+'"/>'+
'<script>'+
'var w, h;'+
'var img=document.images[0];'+
'if(navigator.appName=="Opera"){w=img.width+10; h=img.height+40} else {w=img.width+10; h=img.height+25};'+
'self.resizeTo(w, h);'+
'self.moveTo((screen.availWidth-img.width)/2,(screen.availHeight-img.height)/2)'+
'<\/script>'+
'<style>body{margin:0; padding:0;} .hd{visibility:hidden;}<\/style>');
imgPopup.document.write('<p class="hd">ok</p>');
imgPopup.document.close();
imgPopup.focus();
}
} // shawl.qiu script
}
//---------------------------------end function fResizeImg();
//]]>
</script>
</head>
<body>
<table width="100%" border="1" id="table">
<tr>
<td><img src="temp/2006-10-15/01.jpg" width="400" height="381" /></td>
<td><img src="mod/system/themes/default/default/images/gi_logo_88_31.png" width="88" height="31" /><img src="images/04.jpg" width="640" height="467" /></td>
<td><img src="mod/system/themes/default/default/images/gi_logo_88_31.png" width="88" height="31" /></td>
</tr>
<tr>
<td><img src="mod/managemain/themes/default/default/images/gi_logo_300_92.png" width="300" height="92" /></td>
<td><img src="images/03_1.jpg" width="832" height="1126" /></td>
<td><img src="images/gi_logo_300_92.png" width="300" height="92" /></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
</body>
</html>