Replace commas with CSS in CSS

We use the CRM database, which is accessed through the web console interface. One of the merge fields obtained from the database is the site address, which is returned as a single-line string, separated by commas, and not the address format used for mailing addresses.

That is, instead of:

45 Seafield Place
FORT WILLIAM
PH33 4XJ

... he inserts:

45 Seafield Place, FORT WILLIAM, PH33 4XJ

As a proprietary product, we do not have access to the web server configuration or the ability to modify the PHP used to create pages in it. Templates for customer letters are fully customizable and are simple HTML, with a CSS block @media printto control the style when letters are printed directly from the browser (similar to Google Docs).

Since I cannot control the content or use JavaScript / JQuery to perform text replacement, is there any way to CSS to replace each comma in the class with a tag <br>?

+4
source share
1 answer

, - javascript.
, javascript , " " javascript, .

, , javascript- onload body, , javascript, .

<body onload="var spans = document.querySelectorAll('span');spans[0].innerHTML=spans[0].innerHTML.replace(/,/g,'<br/>');">
    <span>
        45 Seafield Place, FORT WILLIAM, PH33 4XJ
    </span>

</body>

UPDATE

javascript :

<body onload="var spans = document.querySelectorAll('span');spans[0].innerHTML=spans[0].innerHTML.replace(/,/g,'<br/>'); document.getElementsByTagName(
'body')[0].removeAttribute('onload');">
    <span>
        45 Seafield Place, FORT WILLIAM, PH33 4XJ
    </span>

</body>

2-

0

Source: https://habr.com/ru/post/1544600/


All Articles