| 
	
	
		
		
			
			 
				Закрытие блока по клику вне блока или по кнопке закрыть
			 
			
		
		
		
		maximamus,
  
<!DOCTYPE HTML>
<html>
<head>
    <title>Untitled</title>
    <meta charset="utf-8">
    <style type="text/css">
        #divwin4 {
            background-color: #008000;
            width: 150px;
            height: 150px;
            display: none;
        }
        #closeButton {
            background-color: #FF0000;
        }
    </style>
</head>
<body>
    <div id="btopen">
        <a>open</a>
    </div>
    <div id="divwin4">
        <div id="closeButton" onclick="">close</div>
        Текст который открывается можно кликать
    </div>
    <script type="text/javascript">
        var doc = document,
            div = doc.getElementById("divwin4");
        doc.onclick = function(a) {
            for (a = a.target; a != doc;) {
                if ("closeButton" == a.id) {
                    div.style.display = "none";
                    return
                }
                if ("btopen" == a.id) {
                    div.style.display = "block";
                    return
                }
                if ("divwin4" == a.id) return;
                a = a.parentNode
            }
            div.style.display = "none"
        };
    </script>
</body>
</html>
 
		
	
		
		
		
		
		
		
		
						  
				
				Последний раз редактировалось рони, 11.08.2015 в 14:04.
				
				
			
		
		
	
		
		
	
	
	 |