测试
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>");