H4m4k
October 12, 2020, 11:10am
1
Hello
I am working my way through the MDN JS tutorials and am stuck just before the test your skills part.
The problem I want to solve is connected to the images not showing up in the message box.
Correct
Wrong
GitHub works fine:
GitHub - Live
GitHub - Code
My version doesn’t - colors are changing depending on the type of parameter, so that part works. I have tried solving the problem with relative path and to no avail.
if (msgType === 'warning') {
msg.style.backgroundImage = 'url(icons/warning.png)';
panel.style.backgroundColor = 'red';
} else if ( msgType === 'chat') {
msg.style.backgroundImage = 'url(icons/chat.png)';
panel.style.backgroundColor = 'aqua';
} else {
msg.style.paddingLeft = '20px';
}
What I did find though is this
The
inline style has the background-image value set with double, double quotes.
Is this the source of the problem ?
Hello @H4m4k
is this the topic you talking about
With most of the essential theory dealt with in the previous article, this article provides practical experience. Here you will get some practice building your own, custom function. Along the way, we'll also explain some useful details of dealing...
could you share the full code in any of the online sharing service like codepen or jsfiddle or anything else
and have a nice day
H4m4k
October 15, 2020, 8:56pm
3
Hello @justsomeone
yes that is the exact topic I had in mind.
and a nice day for You too
Hello @H4m4k
you need to put the image file in your project if you inspect the result panel
you would see it can not load the image
and from this screen shoot i only see the html file in your project
the full path to the image is
https://mdn.github.io/learning-area/javascript/building-blocks/functions/icons/chat.png
so change this
msg.style.backgroundImage = 'url(icons/warning.png)';
to this
msg.style.backgroundImage = 'url(https://mdn.github.io/learning-area/javascript/building-blocks/functions/icons/chat.png)';
hope that help and have a nice day