Solution 1 :

Might be untidy but would work.

using an escape character

onclick="MapPopUp('Example','hi nr how are you doing')"

and your MapPopUp function can look something like this.

   function MapPopUp(header, content) {
      PopUpHeader.innerHTML = header;
      let contentHtml = '';
      content.split('nr').forEach(c => {
        contentHtml += `<p>${c.trim()}</p>`;
      PopUpContent.innerHTML = contentHtml;

Solution 2 :

Try this.

    div= document.getElementById("popUp");
    br = document.createElement("br");

Problem :

I’m trying to write out a p in my onclick=(”,”) with linebreaks, but br wont work.

I want to be able to do this:

how are you doing?’


<area shape="circle" coords="200,38,28" onclick="MapPopUp('Example','hi how are you doing')" alt="">

<div id="popUp" class="hidden">
            <h3 id="popUpHeader"></h3>
            <p id="popUpContent"></p>
                <a onclick="CloseMapPopUp();">
                    <img id="close" src="images/close.png" alt="close button">


function MapPopUp(header, content) {
    PopUpHeader.innerHTML = header;
    PopUpContent.innerHTML = content;

function CloseMapPopUp() {
    PopUpHeader.innerHTML = "";
    PopUpContent.innerHTML = "";

var PopUpDiv = document.getElementById("popUp");
var PopUpHeader = document.getElementById("popUpHeader");
var PopUpContent = document.getElementById("popUpContent");

I hope someone out there can help
In advance thanks for your help!!!


Comment posted by Arturas Lapinskas

innerHtml creates just a text string with ‘
‘ inside?

Comment posted by Arturas Lapinskas

You should add a dom element, instead of a string, i think

Comment posted by Arturas Lapinskas

You can also try n or nr instead of the