HTML - Includes In Html File
I've acquired a series of websites that, unfortunately, were all created using Dreamweaver and as such all use purely html files.
I need to include a "widget" of sorts across all the websites. It is written in php, hence I'm looking for a way to simply include this php file in the sidebar of all of the websites, which are written in html. This also means I'll be including the file from a different domain using the full URL I gave SSI a shot, but no luck. Similar TutorialsSo I bought a template a while back that has a lot of includes files, which don't really work for me. Whenever the includes file tries to link to another page in the website it points to a /includes first so instead of linking to index.htm it links to includes/index.htm Obviously this links to a page that doesn't exist which leads to a junky website with a ton of broken links. I've already tried "recalculte hyperlinks" and it didn't help at all. Does anybody have any idea or ever experienced this before? Thanks for any help that you guys can give. =D hi everybody, I am working in a html. I defined a functiion in a html file.(first.html) I want to call that function in another html file.(second.html) How can i call that function in second.html file? give some sample code Thanks in advance.... Hi, I'm trying to include one HTML file in another. I tried iframe and was displeased with the results, I want the size of the frame to change dynamically and not just scroll. Fair warning, my knowledge of JavaScript is non-existent >_> . Basically, I have a document written in HTML (please don't suggest a wholesale re-write, that's simply not practical) and the idea is to have one file where it makes sense to include it several times. One thing to mention, this document is not meant to be shown on a web-server, but in a browser while you're reading it off your hard-drive. Here's what I have so far. main.shtml Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>test</title> </head> <body> <center> <h1> This is only a test! </h1> </center> <p> Still testing!!!!! </p> <!-- #include file="included.html" --> <p> Even more testing!!!!! </p> </body> </html> included.html Code: <!--<html> <head> <title> asdfasdfasdfasd </title> </head> <body>--> <p> <h4> foobar </h4> <br> <br> <br> <br> <h4> boofar </h4> </p> <!--</body> </html>--> Not sure what I'm doing wrong, help appreciated! Hi ,I am new in html.Hope you can guide me step-by-step on this. I want to import my .txt file into the html form and the html form can add new item then to be add in to that particular .txt file too as well. can this be done? For example: (fruits.txt) 1.apple 2.banana 3.orange Can this fruit.txt be impoted to fruit.html page and show it at fruit.html page, at the same time, the fruit html page allow to add in new fruit, and once user add in new fruit, the fruit.txt file will be updated as well. Thanks for your guidiance and help. :-) I have a website where I want to make a drop down menu that will bring you to different pages. It is a very basic, sort of old-fashioned website that relies entirely on html. What I'm trying to do is make a drop-down menu that will be used as navigation for a section of a website and I want to have it in each internally linked page in that section, but I'm going to be adding more pages to it over time so I want to be able to put the drop-down menu code in a separate text file and then substitute it into the pages that I make that the options in the menu link to and then just edit the code in the text file when I add another page so that I don't have to go back and edit the code every single individual page whenever I add a new one among them. Basically all I'm asking is how I can put html code in a text file and then substitute that code into an html page by referring to the file. Thanks in advance for any help. I have a script for a navigation bar that I want to include on all my HTML pages using some kind of include tag so that I don't have to paste the script into each page every time I edit it. The only way I can get it to work is if I use either PHP or SSI include tags but this requires me to change all my page extensions from .html to .php or .shtm. So I can get it to work, but the thing is, I don't want to have to change all my extensions. I like my pages in .html and it would be a pain change them all. Is there a way to do what I am trying to do without having to change all my extensions? Some kind of HTML equivalent for include tags? Or some code that forces my HTML documents to read PHP or SSI tags? There's got to be something right? If I have many PHP includes, will this slow down the loading of the page? I may have around 6 at a time on a single page. <? $path = $_SERVER['DOCUMENT_ROOT']; $path .= "/item.php"; include_once($path); ?> I usually have around 6 of these on a page at a time, will this slow down the loading of my website. I use this for updating my website, since all the includes come from the same sources, e.g. navbar on all pages comes from /include/navbar.php then I will have to edit navbar.php to edit the navbar on all pages. Am I using the correct method for website updating, or is there a more efficient way? hey everyone. i'm taking a course in website design this semester and we've gotten to SSI which I am a bit confused over. we're supposed to have built a page with header, menu, footer and then we will be using those three on another 4 pages. so he wants us to pull the header, menu, footer code out and use it with SSI. my question is, what do i need to pull out of this code to make a SSI file that i can then bring in on various pages so they look the same on each? the site is at: http://thing.cs.usm.maine.edu/~mckenney/demo/index.html Okay, so I have a small issue here. I started a webcomic, and I'm now redesigning the website. I'm using SSI includes on my pages, and I'm having an issue with my navigation. I want to be able to include first comic/previous comic/next comic/current comic buttons, but the problem is this: with the previous comic/next comic buttons, I'm not really sure how to code it. I can't type in the name of the page I want it to go to, because then it'll be the same on every page. Is there a way around this? I figured I could tell it to go "next" and have it refer to "next" somewhere on the individual pages, which would send it to the next comic in the sequence, but I can't find the coding to do that, and I can't figure out the right way to word it to find it in a search. If I'm not too vague, can you guys help me out here? Thanks! Hi all, brand new here. A little history. I am an employee of a very small company that had a website built for them. I was given the task of updating it on a regular basis (it is for a group of movie theatres, so it is updated constantly). Well it was build 4 years ago now and the person who built it used frames. We are wanting to bring it a little up to date so I'm redesigning one at the moment that was be much more simplified. What I'm trying to accomplish is this: I want to be able to have a page that has Form - List/Menu that has the days that each theatre has movies scheduled for. Then, when that date is selected, the showtimes part of the page changes to show that dates showtimes but the rest of the page stays the same. After doing some research I THINK what I need to be using is Server Side Includes...but I'm having trouble figuring out how to get this to work. If you want an example of what I'm after you can go to any major movie theatre chain's website (like movietickets.com) and they have what I'm trying to accomplish. ANY help would be appreciated. Thanks! Hi guys I want to add some php files into my frontpage html files, please let me know how to do this. I tried many things but fail. Please guide me. Thank you GCS Hi all, I'm working on a project to make my job a little easier. A brief description is that I have to write up case notes and when I am finished with the notes I submit them. What I am looking for is a code so when I hit the submit button on the tool I created, it will create a log file and save my case notes to that log file. The tool that I created is html based and it's on my local computer. I would also like for it to create the log file on my local computer. Is this possible? A good example is like a messenger service like msn or yahoo IM. When you are done talking to someone it creates a log file of the conversation. Im looking for something like that but that creates a log when I hit the submit button. Any ideas? Best regards, Kris Hi all! I've got a very strange problem with a webpage: If you type http://www.varbanovsoft.com/ images are not correctly displayed but if you type http://www.varbanovsoft.com/index.html they appear!! Any idea? I'm completely lost ... Thanks!! T Introduction: Seeing as this question is brought up very often, I hope this short guide will be a destination for users seeking information about the topic. Although this is a server-side issue, those who are not aware of this fact generally seek help in HTML/XHTML, so this is where the topic will remain Note: Read the answers to Frequently Asked Questions in the next post! Hasn't this been done before? Absolutely; this is meant as a straightforward stickied version that brings a few things together and references previous threads where you can find further details. If your question is somewhere in the realm of one of these, you're in the right place: How do large websites manage their content? How do I make the same content appear in multiple pages without copy/pasting? How do I automatically update parts of different pages, without editing every file? How do I avoid duplicating code in multiple files? Is there an alternative to IFrames? The answer is using PHP Includes, SSI (Server Side Includes), or ASP Includes. Each will be discussed below. Basic Concept: Let's assume we have a basic HTML page with a few links that represent a navigation menu (we're using HTML5 markup for simplicity): Code: <!doctype html> <html> <head> <meta charset="UTF-8"> <title>Main Page</title> </head> <body> <div> <ul> <li><a href="home.html">Home Page</a></li> <li><a href="gallery.html">Gallery Page</a></li> <li><a href="about.html">About Page</a></li> <li><a href="contact.html">Contact Page</a></li> </ul> </div> </body> </html> This HTML page is now our basic template for subsequent pages that we create, which traditionally meant that we copy and paste our menu into each one. However, what if we end up creating 50 pages and then find out we have to add another link to the menu? Our only solution would be to add the link to each page. In order to avoid this, we separate our menu from the rest of the page like so: Code: <div> <ul> <li><a href="home.html">Home Page</a></li> <li><a href="gallery.html">Gallery Page</a></li> <li><a href="about.html">About Page</a></li> <li><a href="contact.html">Contact Page</a></li> </ul> </div> Save it in a file, and then place an include on every page where we want to display the menu: Code: <!doctype html> <html> <head> <meta charset="UTF-8"> <title>Main Page</title> </head> <body> code for including menu would go here </body> </html> This setup lets us update our menu file, and have the changes be immediately reflected everywhere we placed our include. The concept is most often used with things like menus, headers, and footers, but it can be used with anything and we'll now discuss how it's done in practice. Note: The attached zip contains working examples of all three methods. PHP Includes: General Requirements: Your web-hosting provider must support PHP, which most of them do. If your host does not support PHP, I would suggest switching hosts. If you do not have a hosting provider, and you're attempting this on your local computer, it must be set up as a local server and configured to run PHP. The easiest way to do this at once is by installing XAMPP. Required Filetypes: By default, servers will only parse PHP code inside files with the .php extension. Therefore, you must change the extension of any files you want to use includes in to .php (e.g. index.html becomes index.php). Although your main file must have a .php extension, you can include files with extensions such as .html, .txt, .inc, other .php files, and more. Syntax Here are two ways to include a file in PHP: PHP Code: <?php include('file_to_include.html');?> or: PHP Code: <?php include 'file_to_include.html';?> Note that you can also include full URLs if URL file-access is enabled in your server's configuration: PHP Code: <?php include("http://www.google.com/");?> Code Example: (some_page.php) Code: <!doctype html> <html> <head> <meta charset="UTF-8"> <title>PHP Include</title> </head> <body> <?php include("menu.html");?> </body> </html> Server Side Includes (SSI): General Requirements: Your web-hosting provider must support Server Side Includes, which most of them do. If you do not have a hosting provider, and you're attempting this on your local computer, it must be set up as a local server and configured to support Server Side Includes. If you are using Apache, you can find information on enabling SSI here. If you are using IIS, you can install Server Side Includes inside Windows Features > World Wide Web Services > Application Development Features > Server Side Includes, although this path may differ depending on your version of Windows. Required Filetypes: By default, servers will only parse Server Side Includes inside files with the .shtml, .shtm or .stm extensions. Therefore, you must change any files you want to use includes in to have one of these extensions (e.g. index.html becomes index.shtml). Although your main file must have one of the above extensions, you can include files with extensions such as .ssi, .html, .txt, .inc, and more. Syntax Here are two ways to include a file using SSI: Code: <!--#include file="menu.ssi" --> Is used to specify a relative path, i.e. a path to your include in relation to where your main file is. The above assumes that your main file, and menu.ssi are in the same directory. Code: <!--#include virtual="includes/menu.ssi" --> Is used to specify a path relative to the web root. The above assumes that menu.ssi is located inside webroot/includes Code Example: (some_page.shtml) Code: <!doctype html> <html> <head> <meta charset="UTF-8"> <title>SSI Include</title> </head> <body> <!--#include file="menu.ssi" --> </body> </html> ASP Includes: General Requirements: Your web-hosting provider must support ASP. If you do not have a hosting provider, and you're attempting this on your local computer, it must be set up as a local server and configured to support ASP. If you are using Apache, you can find information on enabling ASP here. If you are using IIS, you can install ASP inside Windows Features > World Wide Web Services > Application Development Features > ASP, although this path may differ depending on your version of Windows. Required Filetypes: By default, servers will only parse ASP code inside files with the .asp extension. Therefore, you must change the extension of any files you want to use includes in to .asp (e.g. index.html becomes index.asp). Although your main file must have a .asp extension, you can include files with extensions such as, .html, .txt, .inc, other .asp files, and more. Syntax Here are two ways to include a file using ASP (The syntax is exactly the same as SSI): Code: <!--#include file="menu.html" --> Is used to specify a relative path, i.e. a path to your include in relation to where your main file is. The above assumes that your main file, and menu.html are in the same directory. Code: <!--#include virtual="includes/menu.html" --> Is used to specify a path relative to the web root. The above assumes that menu.html is located inside web root directory/includes Code Example: (some_page.asp) Code: <!doctype html> <html> <head> <meta charset="UTF-8"> <title>ASP Include</title> </head> <body> <!--#include file="menu.html" --> </body> </html> I have an .swf file I have created (an internet banner), and I need to be able to upload it to my webpages such as myspace, etc. I have the .swf file loaded into www.photobucket.com -- how do I embed this into html? I need help ASAP so please respond PS- please keep it newbie-fied... yes, I am a noob to html and am attempting to learn alot... so keep it easy, please -blindman How do you convert a doc file into HTML using aspnet? here is what im trying to do $File = $subject.html; but all it is doing is adding what i type in as the subject and then it adds "html" to the end of it... so if the subject was "pizza" it would come out as "pizzahtml" instead of "pizza.html" what am i doing wrong? I was wondering how I can go about making a single HTML page that all my pages reference to place menus and pictures. The only thing I want to change is content in the middle portion of the page but I don't want to use frames. I have a css already made and that works wonderfully it's just a bit tedious to go through and edit each html document individually every time I change something on the menu's or pictures. As far as I can tell I can't do that in the CSS (place the HTML code directly I mean for divs and such). Any help is greatly appreciated. How to run a batch file in HTML page? Hi, Im trying to make a jsp page but dont know how to let the user select a file from their home directory using HTML. Something similar to the JFileChooser in java is what im hoping for. Any ideas? |