因为ISAPI与其他ISAPI无法同时使用,所以我无法使用PHP。通常情况下,我可以创建
但是现在,由于文件必须使用.htm扩展名,我想知道如何从其他文件中包含内容,例如:如果我有
index.php
和header.php
文件,然后在index.php
中使用include()函数。但是现在,由于文件必须使用.htm扩展名,我想知道如何从其他文件中包含内容,例如:如果我有
index.htm
、header.htm
和other.htm
文件。
header.htm
看起来像这样: <head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=0">
<meta name="description" content="">
<meta name="author" content="">
<title>Dashboard</title>
<!-- Bootstrap core CSS -->
<link href="css/customBootstrap/bootstrap.min.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="css/styles.css" rel="stylesheet">
<!-- Fonts -->
<link href="css/fa-4.0.3/font-awesome.min.css" rel="stylesheet" type="text/css">
<link href='http://fonts.googleapis.com/css?family=Muli' rel='stylesheet' type='text/css'>
<!-- Favicon -->
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<link rel="icon" href="favicon.ico" type="image/x-icon">
<!-- Just for debugging purposes. Don't actually copy this line! -->
<!--[if lt IE 9]><script src="../../docs-assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
<![endif]-->
<!-- FontAwesome Fix for IE7 -->
<!-- [if IE 7]>
<link href="css/fa-3.2.1/font-awesome.min.css" rel="stylesheet" type="text/css" />
<link href="css/fa-3.2.1/font-awesome-ie7.min.css" rel="stylesheet" type="text/css" />
<![endif]-->
</head>
我希望在任何其他文件中,无需将相同内容复制到顶部(因此只需要更改一个文件)。
我应该如何做? 我尝试了类似于这样的东西,它可以工作。 但是,它有一点延迟(因此,用户将在加载正确之前看到一个没有CSS样式的页面)。
<!DOCTYPE html>
<html lang="en">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
$(function(){
$("#header").load("../../common/header.htm");
});
</script>
<div id="header">
</div>
<body>
....
需要帮忙吗?
谢谢你
<head>
的资源。使用CSS文件和$(function(){...})
,你最终会得到一个FOUC(http://en.wikipedia.org/wiki/Flash_of_unstyled_content),这可能会对用户体验造成不良影响。 - Jack