简体   繁体   English

打印Perl CSS和HTML

[英]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. 我使用了一些Perl,最后,我打印了HTML和CSS,以使内容显示在页面上,但是仅显示HTML,CSS样式和JavaScript无法使用。

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? 我删除了一些代码,因为我只是想展示大图,问题是为什么CSS和JavaScript被忽略了? I tried this exact code with PHP using "echo" and it worked perfectly. 我使用“ echo”在PHP上尝试了此确切的代码,并且效果很好。

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 删除每个"字符前的\\字符

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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