1

我正在使用 Boilerplate 4.0,main.js 加载在 body 标记的底部。我正在尝试将页脚编写为脚本,以便更轻松地更新版权年份,即在 main.js 与每个 html 文件中。html 中的函数引用在加载 main.js 之前出现,所以我不断收到“Uncaught ReferenceError: (function) is not defined”错误。我可以在页脚部分之前加载 main.js 并且一切正常,但这不会破坏目的吗?

html代码:

    <footer id="page-footer">
        <script src="js/footer.js"></script>
            <h5>
            <script>footera();</script>
            <strong><a href="main.html"><script>footerb();</script></a></strong>
            <script>footerc();</script>
            </h5>
    </footer>

main.js 代码:

    function footera() {
        document.write("Copyright&copy; 2012, "); 
    }
   function footerb() {
    document.write("<name>, "); 
    }
    function footerc() {
        document.write("all rights reserved"); 
    }
4

0 回答 0