Need to remove a <br> with JS/CSS-Collection of common programming errors

Here is how you are going to fix this…

Create a modified script out of the original script and remove the original.

Code


    function fixScript() {
        // Get all the scripts in the page
        var scripts = document.getElementsByTagName( 'script' );

        for(var i = 0; i < scripts.length; i++) {
            // Find the script we need
            if(scripts[i].childNodes[0] != undefined) {
                if(scripts[i].childNodes[0].textContent.indexOf("
") !== -1) { // Get the code from the script newData = scripts[i].childNodes[0].textContent.replace("
", ""); // Remove the old script scripts[i].parentNode.removeChild(scripts[i]); // Create a new script with fixed data var s1 = document.createElement("script"); s1.type = "text/javascript"; s1.textContent = newData; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(s1, s); // Stop break; } } } }

Output


    //

Originally posted 2013-11-15 09:07:02.