The concept here is to verify the URL of the CSS element's id (.boot). If the URL matches, which it does, then it should display "hello world." However, despite everything seeming correct, the expected behavior is not occurring, and the reason behind this remains unclear.
Scenario: A button is present. Upon clicking it, the CSS background URL is checked. If there is a match, an alert is supposed to be triggered.
CSS:
.boot {
width: 1000px;
height: 1000px;
background-image:url(Videos/printgifstart.GIF);
background-repeat: no-repeat;
background-size: 100%;
background-position: center;
position: fixed;
bottom: -150px;
right: 105px;
z-index: 100;
}
HTML + Javascript
<div class="Logo2" id="blogo">
<h1></h1>
<div class="MirroredSmiles"></div>
<button id="ticketb" class="ticketb"
style="height:100px;
width: 75px;
position: fixed;
top: 335px;
left: 200px;
opacity: 0%;"
onclick="tixbPLS">
</button>
<script>
var tix = document.getElementsByClassName('ticket');
var tixb = document.getElementById('ticketb');
var tixc = document.getElementById('ticketc');
var sart = document.getElementById('shopdrawing');
var sart2 = document.getElementById('shopdrawing2');
var sart3 = document.getElementById('shopdrawing3');
var sbakdo = document.getElementById('backdoor2');
tixb.addEventListener('click', tixbPLS);
function tixbPLS() {
if (document.getElementById('boot').style.backgroundImage = url('Videos/printgifstart.GIF'))
{
alert("hello! world!");
}
}
</script>
</div>
I've researched online and many suggest a syntax error might be the culprit. Despite trying various syntax adjustments for hours, the message "hello world" still doesn't appear as intended.
I thought perhaps it only works with images, but even after adding an image, the issue persists.
Attempts using "=" or "==" in place of each other have been unsuccessful.
Considering that everything else in the code seems fine, I experimented with replacing the original if statement with a math equation type if statement and voila, the alert functioned flawlessly.
Evidently, all components except that particular if line seem to be functioning correctly.