?
Solved

html parts...

Posted on 2014-07-13
8
Medium Priority
?
259 Views
Last Modified: 2014-07-17
In a simple html file (without use of php, asp, etc) codes, it is possible to have parts linked/imported from different files. For exampel to have:

indext.html
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <********link header.html***********> 
  <title>JS Bin</title>
</head>
<body>
<div>
    <********link body.html***********> 
</div>
     <********link footer.html***********> 
</body>
</html>

Open in new window


If not, maybe java script or Jekyll is the solution. I prefer java script because I am familiar with it somewhat.

Thank you.
0
Comment
Question by:Mike Eghtebas
  • 3
  • 3
  • 2
8 Comments
 
LVL 3

Assisted Solution

by:Conner Turner
Conner Turner earned 400 total points
ID: 40193497
Hi eghtebas,

Unfortunately in HTML5 there is no way to externally reference or link .html files you could try using the JavaScript method where you can reference a .js file and have your html content included within document.write(""); functions
this would allow you to import them through the use of <script> tags.

HTH,
Conner
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 40193504
HTML has never been able to do that.  If your server supports SHTML with Server Side Includes, you can.  http://en.wikipedia.org/wiki/Server_Side_Includes
0
 
LVL 34

Author Comment

by:Mike Eghtebas
ID: 40193508
Hi Conner and Dave,

Do you have a sample Java Script version I can use to develop what I want?

Thank you,

Mike
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 3

Expert Comment

by:Conner Turner
ID: 40193518
Hi eghtebas,

By using the document,write function to include HTML you can link it within your current .html file

Example:

// Example JavaScript Code
document.write("<p>Write your HTML Inside of the Write Function</p>");
document.write("<h1>Making sure to include new lines of HTML within the wrote function</h1>");
document.write("<p>Indentation and Nesting will not work with some tags</p>");

Open in new window


Then save you JavaScript file with a .js extension and import it into your html file like so:

<!-- Example HTML Code -->
<script src="myFile.js"></script>

Open in new window


Making sure to change the src path to the stored js file.

HTH,
Conner
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 40193581
Well, I do but I have to say that it's not necessarily a good idea.  While you can load content with javascript / AJAX, the search engines won't see it because the search robots still don't run javascript.  You are Much better off using ASP or PHP with their 'include' facilities than using javascript to do this.  The 'includes' become part of the 'original' file that loads and the search robots see everything that was included.
0
 
LVL 34

Author Comment

by:Mike Eghtebas
ID: 40193608
Hi Dave,

Thank you for the good advise. Here the idea is to learn how it is done in java script. So, if you have a sample, you may consider posting it here.

I have done some work with includes in asp but I am not using asp now. It is not an active web page.

Thanks,

Mike
0
 
LVL 84

Accepted Solution

by:
Dave Baldwin earned 1600 total points
ID: 40193619
Here's an example you can try:  http://www.javascriptkit.com/script/script2/ajaxpagefetcher.shtml  JavascriptKit http://www.javascriptkit.com/ and DynamicDrive http://www.dynamicdrive.com/ both have a lot of useful scripts.
0
 
LVL 34

Author Closing Comment

by:Mike Eghtebas
ID: 40202682
Thank you.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question