Your issue is the space between url
and (
in the JS.
So the line:
document.getElementById('banner').style.backgroundImage = "url (../img/fff.png)";
Needs to become:
document.getElementById('banner').style.backgroundImage = "url(../img/fff.png)";
Here's a working example:
window.onload = myFunction;
function myFunction() {
document.getElementById('banner').style.backgroundImage = "url(https://via.placeholder.com/350x350)";
//This function is to change the backgroundimg on launch
}
#banner {
width: 500px;
height: 500px;
background-image: url('https://via.placeholder.com/350x150');
}
<div id="banner"></div>