Я тестировал и отлаживал код для предупреждения отдельно от остальной части моего веб-сайта, и он отлично работает, когда он отдельный, но когда я помещаю код на свой веб-сайт, предупреждение не будет работать.
Код тестового веб-сайта показывает предупреждение о том, что «на этом сайте есть фальшивые новости», но для реального веб-сайта ничего не отображается.
Я пытался отладить код вручную, я пыталсяотладить код с помощью отладчика кода Visual Studio, и я позволю своим друзьям взглянуть на код, и никто не сможет найти ошибку в коде.
Вот некоторые из кодов предупреждений для веб-сайта:
<div class="popup">The Earth Is Flat
<span class="popuptext" id="myPopup"><img src="images/fi.jpg">
<b>ALERT!</b><br>The Blank Device has scanned this website and found Fake News. The phrase "The Earth is flat." is Fake News.</span>
</div>
Это код предупреждения на тестовом веб-сайте, где он работает:
<div class="popup">The Earth Is Flat
<span class="popuptext" id="myPopup"><img src="images/fi.jpg">
<b>ALERT!</b><br>The Blank Device has scanned this website and found Fake News. The phrase "The Earth is flat." is Fake News.</span>
</div>
Это код JavaScript на обоих веб-сайтах:
function myFunction() {
var popup = document.getElementById("myPopup");
setTimeout(function(){ popup.classList.toggle("show");}, 3000);
}
И этоCSS:
position: relative;
display: inline-block;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
/* The actual popup */
.popup .popuptext {
visibility: hidden;
width: 160px;
background-color: #FF0000;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 8px 0;
position: absolute;
z-index: 1;
bottom: 125%;
left: 50%;
margin-left: -80px;
}
/* Popup arrow */
.popup .popuptext::after {
content: "";
position: absolute;
top: 100%;
left: 50%;
margin-left: -5px;
border-width: 5px;
border-style: solid;
border-color: #FF0000 transparent transparent transparent;
}
/* Toggle this class - hide and show the popup */
.popup .show {
visibility: visible;
-webkit-animation: fadeIn 1s;
animation: fadeIn 1s;
}
/* Add animation (fade in the popup) */
@-webkit-keyframes fadeIn {
from {opacity: 0;}
to {opacity: 1;}
}
@keyframes fadeIn {
from {opacity: 0;}
to {opacity:1 ;}
}
Код тестового веб-сайта показывает предупреждение о том, что «на этом сайте есть фальшивые новости», но для реального веб-сайта ничего не отображается.