1.图片轮番结合放大
// JavaScript Document
var $ = function(id){return typeof id == 'string' ? document.getElementById(id) : id;};function Each(a,fn){for(var i=0;i<a.length;i++)fn.call(a[i],i,a)};function on(o,type,fn){o.attachEvent?o.attachEvent('on'+type,function(){return fn.call(o)}):o.addEventListener(type,fn,false);return on;};
var big=$("bigp");
var cont=$("content");
var smallimg=cont.getElementsByTagName("img");
var small_url = cont.getElementsByTagName("img")[0].getAttribute("src");;
(function(){
Each(smallimg,function(i){
on(smallimg[i],'mouseover',function(){
Each(smallimg,function(j){
if(i==j){
big.src=smallimg[j].src;
big.alt=smallimg[j].alt;
small_url = cont.getElementsByTagName("img")[j].getAttribute("src");
smallimg[j].className="lion";
}else{
smallimg[j].className="";
}
});
});
});
})();
var smalmg = $("fangdj");//Obj
var showimg = $("showimg");//滤镜图片
var bigimg = $("bigimg");//右大图
var show_half = maxWidth = maxHeight = 0;
smalmg.onmouseover = function(){
showimg.style.display = "block";
bigimg.style.display = "inline";
show_half = showimg.offsetHeight/2;
maxWidth = smalmg.clientWidth - showimg.offsetWidth;
maxHeight = smalmg.clientHeight - showimg.offsetHeight;
//上面两个变量指明showimg允许活动的区域
};
smalmg.onmousemove = function(e){
e = e || window.event;//兼容多个浏览器的event参数模式
var num=bigimg.clientWidth/showimg.clientWidth;
var Top = mousePosition(e).y - smalmg.offsetTop - show_half;
var Left = mousePosition(e).x - smalmg.offsetLeft - show_half;
//获取当前移动的showimg位置 计算方法是 鼠标坐标 - 最外面容器的坐标 - 滤镜图的宽(高)的/2
Top = Top<0?0:Top>maxHeight?maxHeight:Top;
Left = Left<0?0:Left>maxWidth?maxWidth:Left;
showimg.style.top = Top + "px";
showimg.style.left = Left + "px";
bigimg.style.background = "url("+small_url+") -"+Left*num+"px -"+Top*num+"px no-repeat";
};
smalmg.onmouseout = function(){
showimg.style.display="none";
bigimg.style.background ="";
bigimg.style.display="none"
};
function mousePosition(ev) {
return {
x:ev.clientX + (document.body.scrollLeft || document.documentElement.scrollLeft),
y:ev.clientY + (document.body.scrollTop || document.documentElement.scrollTop)
}
}
2.微博分享
<script type="text/javascript" src="http://v3.jiathis.com/code/jiathis_r.js?uid=1342582394583517&type=left&move=0&btn=l5.gif" charset="utf-8"></script>