验证图片大小

测试
news.sohu.com
news.sina.com.cn
news.163.com
sina和163的没有jquery
所以先加这行代码
javascript:document.body.innerHTML +="<scri"+"pt type='text/javasc"+"ript' src='http://js.sohu.com/library/jquery1.3.2.js'></scr"+"ipt>";

保存到收藏夹
在把下面代码保存成一行,也保存到收藏夹

javascript:
document.body.innerHTML +="<scri"+"pt type='text/javasc"+"ript'>var oldimgcount=$('img').size();;function getNewsSohuComImg_hao(thisurl,thisid){$('#picdiv').html(thisurl+';'+$('#picdiv').html());}function createImgPic_haonn(){var imgarray=$('#picdiv').text();imgarray=imgarray.split(';');var tmpstr='';for(var imgarrayindex=0;imgarrayindex<imgarray.length-1;imgarrayindex++){tmpstr+='<img id=haha'+imgarrayindex+' src='+imgarray[imgarrayindex]+' />';$('#picdiv').html(tmpstr);}}function countImgSize_haonn(){$('img').each(function(index){if(index>=oldimgcount){$('#jieguo').html($(this).attr('src')+' width:'+$(this).width()+' height:'+$(this).height()+'</br>'+$('#jieguo').html());}});}function countImgUrl_haonn(){for(var thisi=0;thisi<$('img').size();thisi++){var ull=$('img').eq(thisi).attr('src');getNewsSohuComImg_hao(ull,'haohao'+thisi);}}</scri"+"pt>";
document.body.innerHTML +="<hr /><input type='button' onclick='countImgUrl_haonn()' value='提取url'/>";
document.body.innerHTML += "<input type='button' onclick='createImgPic_haonn()' value='生成图片'/>";
document.body.innerHTML +="<input type='button' onclick='countImgSize_haonn()' value='判断大小'/>";
document.body.innerHTML +="<div id='jieguo'></div>";
document.body.innerHTML +="<div id='picdiv'></div>";


new.163.com
依次点完两个收藏夹之后
页面的最下面出现3个按钮
最后生成图片预览和图片大小
----------------------------
其他
test1.html
<html>
<head>
<title>mytest</title>
</head>
<body>
<script type="text/javascript" src="http://js.sohu.com/library/jquery1.3.2.js" ></script>
<img src="http://ww1.sinaimg.cn/large/67b98b3djw1dptmqg51lbj.jpg" width="100" height="100" style="width:100;height:100"/>
<img src="http://ww2.sinaimg.cn/large/6966d53egw1dptmcb4663j.jpg" width="100" height="100" style="width:100;height:100"/>

</body>
</html>
<script type="text/javascript">
$("body").append("<hr /><input type='button' onclick='countImgUrl_haonn()' value='提取url'/>");
$("body").append("<input type='button' onclick='createImgPic_haonn()' value='生成图片'/>");
$("body").append("<input type='button' onclick='countImgSize_haonn()' value='判断大小'/>");
$("body").append("<div id='jieguo'></div>");
$("body").append("<div id='picdiv'></div>");
//$("body").append("<scri"+"pt type='text/javascript'>alert('haha');</scri"+"pt>");
//-----------下面代码不要有注释----生成一行给test2.html
var oldimgcount=$('img').size();
function getNewsSohuComImg_hao(thisurl,thisid){
$('#picdiv').html(thisurl+';'+$('#picdiv').html());
}
function createImgPic_haonn(){
var imgarray=$('#picdiv').text();
imgarray=imgarray.split(';');
var tmpstr='';
for(var imgarrayindex=0;imgarrayindex<imgarray.length-1;imgarrayindex++){
tmpstr+='<img id=haha'+imgarrayindex+' src='+imgarray[imgarrayindex]+' />';
$('#picdiv').html(tmpstr);
}
}
function countImgSize_haonn(){
$('img').each(function(index){
if(index>=oldimgcount){
$('#jieguo').html($(this).attr('src')+'---width:'+$(this).width()+',height:'+$(this).height()+'</br>'+$('#jieguo').html());
}
});
}
function countImgUrl_haonn(){
for(var thisi=0;thisi<$('img').size();thisi++){
var ull=$('img').eq(thisi).attr('src');
getNewsSohuComImg_hao(ull,'haohao'+thisi);
}
}
</script>

test2.html

<html>
<head>
<title>mytest</title>
<script type="text/javascript" src="http://js.sohu.com/library/jquery1.3.2.js" ></script>
</head>
<body>

<img src="http://ww1.sinaimg.cn/large/67b98b3djw1dptmqg51lbj.jpg" width="100" height="100" style="width:100;height:100"/>
<img src="http://ww2.sinaimg.cn/large/6966d53egw1dptmcb4663j.jpg" width="100" height="100" style="width:100;height:100"/>
</body>
</html>
<script type="text/javascript">
// document.body.innerHTML +="<scri"+"pt type='text/javasc"+"ript' src='http://js.sohu.com/library/jquery1.3.2.js'></scr"+"ipt>";

$("body").append("<scri"+"pt type='text/javasc"+"ript'>var oldimgcount=$('img').size();function getNewsSohuComImg_hao(thisurl,thisid){$('#picdiv').html(thisurl+';'+$('#picdiv').html());}function createImgPic_haonn(){var imgarray=$('#picdiv').text();imgarray=imgarray.split(';');var tmpstr='';for(var imgarrayindex=0;imgarrayindex<imgarray.length-1;imgarrayindex++){tmpstr+='<img id=haha'+imgarrayindex+' src='+imgarray[imgarrayindex]+' />';$('#picdiv').html(tmpstr);}}function countImgSize_haonn(){$('img').each(function(index){if(index>=oldimgcount){$('#jieguo').html($(this).attr('src')+'---width:'+$(this).width()+',height:'+$(this).height()+'</br>'+$('#jieguo').html());}});}function countImgUrl_haonn(){for(var thisi=0;thisi<$('img').size();thisi++){var ull=$('img').eq(thisi).attr('src');getNewsSohuComImg_hao(ull,'haohao'+thisi);}}</scri"+"pt>");
$("body").append("<hr /><input type='button' onclick='countImgUrl_haonn()' value='提取url'/>");
$("body").append("<input type='button' onclick='createImgPic_haonn()' value='生成图片'/>");
$("body").append("<input type='button' onclick='countImgSize_haonn()' value='判断大小'/>");
$("body").append("<div id='jieguo'></div>");
$("body").append("<div id='picdiv'></div>");
</script>

------------------
会出现页面变形的问题
如果是sohu的可以使用
javascript:$("body").append("<scri"+"pt type='text/javasc"+"ript'>var oldimgcount=$('img').size();;function getNewsSohuComImg_hao(thisurl,thisid){$('#picdiv').html(thisurl+';'+$('#picdiv').html());}function createImgPic_haonn(){var imgarray=$('#picdiv').text();imgarray=imgarray.split(';');var tmpstr='';for(var imgarrayindex=0;imgarrayindex<imgarray.length-1;imgarrayindex++){tmpstr+='<img id=haha'+imgarrayindex+' src='+imgarray[imgarrayindex]+' />';$('#picdiv').html(tmpstr);}}function countImgSize_haonn(){$('img').each(function(index){if(index>=oldimgcount){$('#jieguo').html($(this).attr('src')+' width:'+$(this).width()+' height:'+$(this).height()+'</br>'+$('#jieguo').html());}});}function countImgUrl_haonn(){for(var thisi=0;thisi<$('img').size();thisi++){var ull=$('img').eq(thisi).attr('src');getNewsSohuComImg_hao(ull,'haohao'+thisi);}}</scri"+"pt>");$("body").append("<hr /><input type='button' onclick='countImgUrl_haonn()' value='text0'/>");$("body").append("<input type='button' onclick='createImgPic_haonn()' value='text1'/>");$("body").append("<input type='button' onclick='countImgSize_haonn()' value='text2'/>");$("body").append("<div id='jieguo'></div>");$("body").append("<div id='picdiv'></div>");
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值