Javascript 如何加载只有url的隐藏内容框?

Javascript 如何加载只有url的隐藏内容框?,javascript,php,jquery,html,Javascript,Php,Jquery,Html,我在网上找不到我想要的东西 我在index.php中有一个div <div id="navigatie_box" class="about"> <h1 class="navigate_title">About</h1> <div class="about_image"></div> </div> 我现在想要的是我的url中的一个位置,因此如果我键入www.example.com/about,隐藏的内容框就会

我在网上找不到我想要的东西

我在index.php中有一个div

<div id="navigatie_box" class="about">
    <h1 class="navigate_title">About</h1>
    <div class="about_image"></div>
</div>

我现在想要的是我的url中的一个位置,因此如果我键入www.example.com/about,隐藏的内容框就会出现并加载其中的内容/about.php

我认为这是一个很难回答的问题,但我真的找不出来


希望您能帮助我。

首先,您必须在.htaccess中创建重写规则 在遇到www.example.com/about时指向index.php文件

还创建规则以发送一个GET参数,例如.htaccess中的页面。 因此,当我们调用www.example.com/about时,它应该像www.example.com/index.php?page=about一样重定向


现在,在index.php文件中,您必须检查是否设置了$\u GET['page'],然后只需显示所需的内容。

不确定是否理解您的问题,但我想您希望这样:

var page = window.location.pathname.split("/").pop();

$(document).ready(function () {
    /* about click */
    $('.about').click(function () {
        $('.about').hide("fast");
        $('.work').hide("fast");
        $('.cv').hide("fast");
        $('.contact').hide("fast");
        $(".content").slideDown("fast");
        $(".content").load("content/" + page + ".php");
    });
});

这是一个基本的代码片段,肯定需要一些改进

所以如果我键入www.example.com/关于你的意思是什么?如果你在哪里输入?我的意思是在我的浏览器中。我现在只有基本的jquery脚本。它加载指定div中的内容,而不更改url或其他内容。因此,我想要的是,如果我键入www.example.com/about,它将在指定的div中加载内容/about。而不单击index.php中的.about按钮,我也在localhost中工作,如下所示:此映射中的localhost/example是my index.php,而我的supmaps是content/about.php。你不明白什么?我想让你们明白一点:我在localhost中工作,就像这样:这个映射中的localhost/example是我的index.php,我的子映射content/about.php与你们相关吗?
$(document).ready(function(){
    /* about click */
    $('.about').click(function() {
    $('.about').hide("fast");
    $('.work').hide("fast");
    $('.cv').hide("fast");
    $('.contact').hide("fast");
    $(".content").slideDown("fast");
    $(".content").load("content/about.php");
    });
var page = window.location.pathname.split("/").pop();

$(document).ready(function () {
    /* about click */
    $('.about').click(function () {
        $('.about').hide("fast");
        $('.work').hide("fast");
        $('.cv').hide("fast");
        $('.contact').hide("fast");
        $(".content").slideDown("fast");
        $(".content").load("content/" + page + ".php");
    });
});