如何链接多个网页?

时间:2017-10-31 10:16:16

标签: javascript php jquery html css

大家好,请帮我解决问题.. 我是网络开发的初学者,我对导航栏有疑问。我创建了一个带导航栏的简单网页。我想使用导航栏将我的其他网页链接到home.php页面。单击导航菜单时,相关网页应显示在home.php网页的内容区域中。我该怎么做?请指导我......

5 个答案:

答案 0 :(得分:2)

你可以使用php include()在每个页面上都有这样的导航

let helperView = HelperView()
navigationItem.titleView = helperView

或只是iframe?

答案 1 :(得分:2)

用于创建不同网页并使用导航栏中的锚标记链接它们。 如果家庭和其他页面在同一目录中,请像这样。 <a href="services.php">Services</a>

答案 2 :(得分:2)

你可以在html标签中使用

示例:

<a href="home.php"></a>

如果home.php位于您在html或php文件中创建菜单栏的同一文件夹中。

File path

答案 3 :(得分:2)

有很多方法可以实现这一目标。最简单的可能是使用包含。首先,定义导航栏文件:

<!-- navigation.php -->
<header>
  <a href="page1.php">Page 1</a>
  <a href="page2.php">Page 2</a>
</header>

然后定义每个页面,包括导航栏文件:

<!-- page1.php -->
<html>
  <body>
    <?php include('navigation.php'); ?>
    <main>
      Page 1 contents here...
    </main>
  </body>
</html>

第2页也有相同的逻辑,依此类推。每次单击导航链接时,新页面都会加载导航栏。

答案 4 :(得分:1)

除了Sarim的回答,您还需要创建一个包含空内容区域的HTML页面,“模板”,然后用您的页面填充此空白区域。 (为避免在所有页面中重复相同的HTML),请记住永远不要在编程堆栈的任何级别重复自己的

例如,模板可能是这样的

<强>的template.php

<html>
<head></head>
<body>
<!-- your navigator and other static content-->
<?=$pageContent?>
</body>
</html>

然后构建您的网页并填写模板的空白内容

<强> home.php

<?php
 // make the page contents any way you want , like:
 $pageContent = "<div>this is the home page content</div>"
 //then include your template
 include('template.php');