1. 程式人生 > 實用技巧 >CTF-i春秋-Web-偏移、置換密碼-破譯-2016全國大學生資訊保安競賽

CTF-i春秋-Web-偏移、置換密碼-破譯-2016全國大學生資訊保安競賽

<!DOCTYPE html>

<html lang="en"> <head> <meta charset="UTF-8"> <title>JS實現放大鏡效果</title> <style> #small{ width: 700px; height: 340px; position: absolute; left: 70px; top: 100px; } #small img{ width: 100%; height: 100%; } #mark{ width: 200px; height: 200px; position: absolute;
opacity: 0.5; filter: alpha(opacity=50); left: 0px; top: 0px; display: none; } #big{ width: 400px; height: 400px; border: 1px solid black; left: 800px; top: 100px; position: absolute; overflow: hidden; display: none; } #big img{ width: 1400px; height: 680px; position: absolute; left: 0px; top: 0px; } </style>
<script> window.onload = function(){ var oSmall = document.getElementById("small"); var oBig = document.getElementById("big"); var oMark = document.getElementById("mark"); var oBigImg = oBig.getElementsByTagName("img")[0]; oSmall.onmouseover = function(){ oMark.style.display = "block"; oBig.style.display = "block";
} oSmall.onmouseout = function(){ oMark.style.display = "none"; oBig.style.display = "none"; } oSmall.onmousemove = function(ev){ var e = ev || window.event; var l = e.clientX - oSmall.offsetLeft - 100; if(l <= 0){ l = 0; } if(l >= (700-200)){ l = 500; } var t = e.clientY - oSmall.offsetTop - 100; if(t <= 0){ t = 0; } if(t >= (340-200)){ t = 140; } oMark.style.left = l + 'px'; oMark.style.top = t + 'px'; /* 右邊圖片移動方向與左邊圖片方向相反且成倍數移動 */ oBigImg.style.left = l * -2 + 'px'; oBigImg.style.top = t * -2 + 'px'; } } </script> </head> <body> <div id="small"> <img src="/*照片路徑*/" alt="怎麼回事"> <div id="mark"></div> </div> <div id="big"> <img src="/*照片路徑*/" alt="怎麼回事"> </div> </body> </html>