简体   繁体   English

当page.html位于另一个文件夹中时,幻灯片菜单停止工作

[英]Slide menu stops working when page.html is in another folder

So I have this side menu which expands once clicked. 因此,我有一个侧面菜单,一旦单击它就会展开。 It works fine in my index.html page and all the other pages that are in the root folder. 在我的index.html页面和根文件夹中的所有其他页面上,它都可以正常工作。

But if I open a page which is inside a folder - for example ../blog/page.html Then the side menu does not work, you can click it but it does not slide out. 但是,如果我打开文件夹内的页面-例如../blog/page.html ,则侧面菜单不起作用,您可以单击它,但不会滑出。 The page uses the same CSS and JS sheets. 该页面使用相同的CSS和JS工作表。

What am I missing? 我想念什么?

Code samples bellow. 代码示例如下。

HTML: HTML:

<!-- Menu -->
                <section id="menu">

                    <!-- Search -->
                        <section>
                            <form class="search" method="get" action="#">
                                <input type="text" name="query" placeholder="Search" />
                            </form>
                        </section>

                    <!-- Links -->
                        <section>
                            <ul class="links">
                                <li>
                                    <a href="#">
                                        <h3>Lorem ipsum</h3>
                                        <p>Feugiat tempus veroeros dolor</p>
                                    </a>
                                </li>
                                <li>
                                    <a href="#">
                                        <h3>Dolor sit amet</h3>
                                        <p>Sed vitae justo condimentum</p>
                                    </a>
                                </li>
                                <li>
                                    <a href="#">
                                        <h3>Feugiat veroeros</h3>
                                        <p>Phasellus sed ultricies mi congue</p>
                                    </a>
                                </li>
                                <li>
                                    <a href="#">
                                        <h3>Etiam sed consequat</h3>
                                        <p>Porta lectus amet ultricies</p>
                                    </a>
                                </li>
                            </ul>
                        </section>

                    <!-- Actions -->
                        <section>
                            <ul class="actions vertical">
                                <li><a href="#" class="button big fit">Log In</a></li>
                            </ul>
                        </section>

                </section>

JS: JS:

        // Menu.
        $menu
            .appendTo($body)
            .panel({
                delay: 500,
                hideOnClick: true,
                hideOnSwipe: true,
                resetScroll: true,
                resetForms: true,
                side: 'right',
                target: $body,
                visibleClass: 'is-menu-visible'
            });

    // Search (header).
        var $search = $('#search'),
            $search_input = $search.find('input');

        $body
            .on('click', '[href="#search"]', function(event) {

                event.preventDefault();

                // Not visible?
                    if (!$search.hasClass('visible')) {

                        // Reset form.
                            $search[0].reset();

                        // Show.
                            $search.addClass('visible');

                        // Focus input.
                            $search_input.focus();

                    }

            });

        $search_input
            .on('keydown', function(event) {

                if (event.keyCode == 27)
                    $search_input.blur();

            })
            .on('blur', function() {
                window.setTimeout(function() {
                    $search.removeClass('visible');
                }, 100);
            });

CSS: CSS:

                        #header .main ul li > a:before {
                        display: block;
                        height: inherit;
                        left: 0;
                        line-height: inherit;
                        position: absolute;
                        text-align: center;
                        text-indent: 0;
                        top: 0;
                        width: inherit;
                    }

Can you post how the javascript files and css are loaded to the page? 您可以张贴javascript文件和CSS如何加载到页面吗? Maybe the path depends on the location of the html file. 也许路径取决于html文件的位置。

As Alex notes, you need to set the right path within each html file. 如Alex所述,您需要在每个html文件中设置正确的路径。 For example, within blog/page.html the path to your scripts would be: ***../**assets/js/whatever-your-script-is.js* 例如,在blog / page.html中 ,脚本的路径为:*** .. / ** assets / js / whatever-your-script-is.js *

Make sure you do this for all script files (query, respond, skull, util, etc). 确保对所有脚本文件(查询,响应,skull,util等)执行此操作。

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

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