created by aha00a at 2021-02-09
last modified by aha00a at 2021-02-09
revision: 1

HTML Include

HTML에 Include 기능이 없다. jQuery를 이용해서 간단히 구현해봄.

custom include 태그로 넣어주고, IDE에서 warning이 뜨지 않게 Suppress 해 주었다.

<body class="main">
    <!--suppress HtmlUnknownTag -->
    <include src="_header.html"></include>

    Content

    <!--suppress HtmlUnknownTag -->
    <include src="_footer.html"></include>
</body>

그리고 ready시에 Ajax로 불러와서 갈아끼워줌.

<script type="text/javascript">
    $(function () {
        $('include').each(function (i, v) {
            $.ajax({
                url: $(v).attr('src'),
                success: function (data, textStatus, jqXHR) {
                    $(v).replaceWith(data);
                },
                error: function (jqXHR, textStatus, errorThrown) {
                    console.log(arguments);
                    debugger;
                }
            });
        });
    });
</script>

--2021-02-09

1. See Also

1.2. Similar Pages

Similar pages by cosine similarity. Words after page name are term frequency.

  • 31.69% jQueryFormPlugin jq(2:7), text(3:4), function(4:3), xhr(2:5), data(2:4), status(2:4), error(2:3), log(1:3), console(1:3), thrown(1:2)

1.3. Adjacent Pages