我有以下json文件
{
"subject":"CSE",
"semester":"Fall",
"number":"219",
"year":"2017",
"title":"Title",
"instructor_name":"Instructor Name",
"instructor_home":"Instructor Home",
"export_dir":"",
"template_dir":"",
"home_page_boolean":true,
"syllabus_page_boolean":true,
"schedule_page_boolean":true,
"hws_page_boolean":true,
"project_page_boolean":true,
"banner_school_image_file":"test.jpeg",
"left_footer_image_file":"test.jpeg",
"right_footer_image_file":"test.jpeg"
}
我还有以下html文件
/*109923473*/
<html>
<head>
<title>CSE 380 Home Page - Spring 2017</title>
<link rel="stylesheet" type="text/css" href="./css/course_homepage_layout.css">
<link rel="stylesheet" type="text/css" href="./css/sea_wolf.css">
<!-- LINK TO OUR JQuery -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
</head>
<body>
<div id="content">
<div id="navbar">
<a href="http://www.stonybrook.edu/"><img class="sbu_navbar" alt="Name" src="./images/ImageLogo.png"></a>
<a id="home_link" class="open_nav" href="index.html">Home</a>
<a id="syllabus_link" class="nav" href="syllabus.html">Syllabus</a>
<a id="schedule_link" class="nav" href="schedule.html">Schedule</a>
<a id="hws_link" class="nav" href="hws.html">HWs</a>
<a id="projects_link" class="nav" href="projects.html">Projects</a>
</div>
<div id="banner">
CSE 380 - Spring 2017<br>
Computer Game Programming
</div>
<div id="desc">
<h4> ANNOUNCEMENTS:</h4>
<p>Welcome to the CSE 380 Web site. </p>
<br><br><br><br><br>
<hr>
json数据不在html文件中。它是一个名为CourseDetails.json的单独文本文件
我需要改变三件事。
有没有办法在html文件中设置变量,将它们设置为json文件中的值,然后只使用变量而不是硬编码数据?
我还有5个布尔json数据变量。那些应该控制导航栏中的哪些网站页面出现。例如,如果json文件包含
“syllabus_page_boolean”:假 “schedule_page_boolean”:假
然后html文件的导航栏部分应该只是
<div id="navbar">
<a href="http://www.stonybrook.edu/"><img class="sbu_navbar" alt="Name" src="./images/ImageLogo.png"></a>
<a id="home_link" class="open_nav" href="index.html">Home</a>
<a id="hws_link" class="nav" href="hws.html">HWs</a>
<a id="projects_link" class="nav" href="projects.html">Projects</a>
</div>
这与第一部分非常相似,但在html文件中我有一个图像的路径文件
<a href="http://www.stonybrook.edu/"><img class="sbu_navbar" alt="Name" src="./images/ImageLogo.png"></a>
如何使用json文件中的路径文件替换硬编码路径文件(left_footer_image)
谢谢!