简体   繁体   中英

Printing Perl CSS and HTML

I'm using a bit of Perl, and at the end, I print HTML and CSS for stuff to appear on the page, but only the HTML appears, the CSS styling and JavaScript doesn't work.

Here's my print code:

    print '

<html>
    <head>
        <link href=\"https://fonts.googleapis.com/css?family=Roboto+Condensed\" rel=\"stylesheet\">

        <style>

            body
            {
                margin: 0;
                padding: 0;
            }

             #faqDiv
            {
                height: 450px;
                width:700;
                background-color: white;
                position: relative;
                top: 50;
                margin: auto;
            }

            #faqicon
            {
                float: right;
                width: 90;
                position: relative;
                top: -70;
                right: 20;

            }

        </style>
    </head>

    <body>
            <div id=\"introdiv\">
                <img src=\"registercrosstwo.png\" id=\"frontcross\">
                <h1 id=\"titledespre\">Despre Familia Crestina Ortodoxa</h1>
                <hr>

                        <button class=\"accordion\">Pr. Cleopa</button>
                        <div class=\"panel\">
                          <p>- Acum va intreb pe voi, se mai fac astazi nunti de acestea? </p>
                        </div>
                </div>
            </div>

    <script>

        window.addEventListener(\"scroll\", function () {
                document.body.classList[
                window.scrollY > 20 ? \"add\": \"remove\"
                ](\"scrolled\");
            });

    </script>
    </body>
</html>    
';

I deleted a bit of code because I just wanted to show the big picture, the question is why is the CSS and JavaScript ignored? I tried this exact code with PHP using "echo" and it worked perfectly.

You are using a single quoted string ' and then attempting to quote " characters. They are then getting passed through to the web browser as \\" confusing it.

Remove the \\ character before each " character

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM