帧的替代是什么? [英] What is the subsitute for frames?

查看:126
本文介绍了帧的替代是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个包含50个网页的网站。每页包含

Lets say I have a web site with 50 web pages. Each page consists of


  1. A标题

  2. 导航

  3. 左侧内容

  4. 右侧内容

  5. 页脚

  1. A Header
  2. Navigation
  3. Left Side Content
  4. Right Side Content
  5. Footer

不使用


  1. 框架

  2. 服务器端编程

  3. 第三方工具和软件

  4. 框架

  1. Frames
  2. Server side programming
  3. Third part tools and softwares
  4. Frameworks

我需要输入代码(50个标记)这50个页面中每个部分中的每个部分都有哪些? Code Once,Use Again& Again这个词怎么了?另外如果我想改变任何东西,我需要在50个地方改变它。这只是简化。我可以这样使用。

I would need to put the code (HTML Markup) for each of these 5 sections in each of those 50 pages? What happened to the term "Code Once, Use Again & Again"? Also If I want to change any thing, I would need to change it at 50 places. This is just reduntant. Can I use as such.

<object type="text/html" height="100%" width="100%" data="header.html"></object>

请原谅我的愚蠢问题。学习硬道!

Excuse my stupid questions. Learning the hardway!

推荐答案

您描述了服务器端语言的确切用例。

You describe the exact use case for a server-side language.

让我向您解释一下您的方法存在的问题。如果你这样做你的网站,有 index.html 和你通过对象包含的其他5个部分或 iframe ,这将意味着向您的服务器发出6个请求(这当然不是一个好习惯)。

Let me explain you the problem with your approach. If you do your site this way, having an index.html and those other 5 parts you include through either object or iframe, this will mean 6 requests to your server (which is certainly not a good practice).

事情会发生如下:


  • 浏览器请求 index.html

  • 解析它并发现它还需要请求 header.html 和其他四个

  • 请求所有这5个htmls来自服务器

  • Browser requests your index.html
  • Parses it and finds it also needs to request header.html and four others
  • Requests all those 5 htmls from the server

相反,你可以请求 index.php 例如(如果你使用PHP),让PHP构建 ONE HTML资源(可能包括其他PHP文件,如 header.php )并将其发送给浏览器,它会愉快地显示它。

Instead, you could just request index.php for example (if you use PHP), let PHP construct ONE HTML resource (possibly including other PHP files, like header.php) and send it to the browser, which will happily display it.

你不必破坏你的学习顺序,只为了这个特定的目的使用一些小部件(根本只使用一个命令) )。要灵活,你会发现它在这项业务中非常有用:)。

You don't have to break your learning order, only use some small parts for this specific purpose (using only one command at all). Be flexible, you will find it very useful in this business :).

举个例子:

index.php

<!DOCTYPE html>
<html>
...
<body>

<?php include 'header.php'; ?>

<?php include 'navigation.php'; ?>

...

<?php include 'footer.php'; ?>

</body>
</html>

在PHP文件中,您只能使用简单的HTML,只有文件扩展名会有所不同。要编写PHP命令,你可以使用<?php中的任何内容?>

In your PHP files, you can have only simple HTML, only the file extension will be different. To write PHP commands you can use <?php whatever ?>

这篇关于帧的替代是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆