Просмотр полной версии : Механизм работы скрипта на сайте МДМ Банка
Здравствуйте.
На сайте МДМ Банка: http://www.mdm.ru/spb/about/ есть ссылка «Весь сайт»:
http://img-fotki.yandex.ru/get/5701/tzhe.0/0_553c4_72f2628f_XL.jpg
При клике на нее мы видим удобную мини карту сайта.
Пожалуйста, объясните механизм работы этой ссылки.
monolithed
29.11.2010, 21:36
Ну примерно как-то так:
<script type="text/javascript">
window.onload = function(){
var element = document.getElementsByTagName('a'), i = element.length;
while(i--){
element[i].onclick = function(i){
return function(){
document.getElementsByTagName('div')[0].style.display = i == 0 ? 'block' : 'none';
};
}(i);
}
};
</script>
<style type="text/css">
div {
background: #B3D5DE;
display: none;
opacity:0.5;
position: absolute;
top: 10px;
left: 10px;
width: 200px;
height: 200px;
}
div a {
display: block;
cursor: pointer;
color: #000;
float: right;
font: bold 18px arial;
position: relative;
text-decoration: none;
}
div a:hover {
color: red;
}
</style>
<a href="#">click</a>
<div><a href="#">&otimes</a></div>
vBulletin® v3.6.7, Copyright ©2000-2025, Jelsoft Enterprises Ltd. Перевод: zCarot