0
I have a modal that opens when the mouse leaves the page. The problem is that when I try to close on X
, she doesn’t close:
<!DOCTYPE html>
<html lang="en" onmouseleave="Open('openModal')">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="style.css">
<title>Document</title>
</head>
<body>
<div id="openModal" class="modalDialog" >
<div>
<a href="#close" title="Close" onclick="close('openModal')"
class="close">X</a>
<h2>Modal Box</h2>
<p>1 paragrafo.</p>
<p>teste teste teste teste teste teste v</p>
</div>
</div>
<script>
function Open(x) {
x = document.getElementById("openModal").style.opacity = "1";
}
function close(x){
y = document.getElementById("openModal").style.opacity = "0";
}
</script>
</body>
</html>
Failed to post the Javascript code that opens your modal... @question: Already tried to add an event
mouseout
on top of thebody
?– LipESprY
I don’t have it yet, because I have no idea how to do it, I’m a beginner, I still have difficulty
– user135751
@Lipespry No, I’ll try
– user135751
"- i can open with a link" The "pure" link does not open the modal. It just "scrolls" the page to where the anchored object is via
id
. Edit the question and put your full page on a snippet. Given your level as a beginner, maybe the code is there and you don’t know. ;D– LipESprY
@Lipespry Vlw for the tip! I will change
– user135751
No, mate! kkkkk! Snippet is where you will paste the source code of your page with the modal... See this image: https://i.stack.Imgur.com/Uo2ve.png In this case, you enter ALL the code. If necessary, I or another colleague edit your question by removing what is not necessary. ;D
– LipESprY
@Lipespry I made some changes
– user135751