Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/472.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript indexOf函数满足php_Javascript_Jquery - Fatal编程技术网

Javascript indexOf函数满足php

Javascript indexOf函数满足php,javascript,jquery,Javascript,Jquery,索引of的作用是什么?我只是将它添加到PHP代码中,并将我的文件名(从index.html更改为homepage.PHP),还将更改为,然后类活动就不起作用了 触发此错误的原因是什么 HTML <nav class="main-navi"> <ul> <li> <a href="index.html" > Home <span cl

索引of的作用是什么?我只是将它添加到PHP代码中,并将我的文件名(从index.html更改为homepage.PHP),还将
更改为
,然后类
活动
就不起作用了

触发此错误的原因是什么

HTML

<nav class="main-navi">
    <ul>
        <li>
            <a href="index.html" >
                Home
                <span class="dot"></span>
                <span class="corner"></span>
            </a>
        </li>
        <li>
            <a href="portfolio.html">
                Portfolio
                <span class="dot"></span>
                <span class="corner"></span>
            </a>
        </li>
        <li>
            <a href="about.html">
                About
                <span class="dot"></span>
                <span class="corner"></span>
            </a>
        </li>
        <li>
            <a href="service.html">
                services
                <span class="dot"></span>
                <span class="corner"></span>
            </a>
        </li>
        <li>
            <a href="blog.html">
                Blog
                <span class="dot"></span>
                <span class="corner"></span>
            </a>
        </li>
        <li>
            <a href="contact.html">
                contacts
                <span class="dot"></span>
                <span class="corner"></span>
            </a>
        </li>
    </ul>
    <em id="showHideMenu" class="show-hide-menu fa fa-bars" href="#"></em>
</nav>

window.location.pathname
仅包含URL的路径部分。使用
window.location.href
在完整URL内搜索:

var loc = window.location.href;
....

但是请注意,如果URL中有更多参数,这种比较可能会失败。

html中的仍然是index.html?当仍然只有html时,我使用index.html,但当我更改为php时,我更改了a href
var loc = window.location.href;
....