Include an external HTML file?

Discussion in 'HTML & Website Design' started by kuser, Jul 4, 2012.

  1. #1
    Hello is there any way i can include in HTML very easy some external text ? like i do in php with include_once function ?
    like i would wish to only have news on www.latinotimes.com/news.html ? and put the news in all pages (right panel)
     
    kuser, Jul 4, 2012 IP
  2. jenev

    jenev Peon

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    0
    #2
    At prima facie I suggest the way with jquery. You can use .load funtion to include external file where you want.

    I searched in Google and find this article:

    Server Side Includes

    SSI, or Server Side Includes, were first developed to allow Web developers to "include" HTML documents inside other pages. If your Web server supports SSI, it's easy to create templates for your Web site.

    Save the HTML for the common elements of your site as separate files. For example, your navigation section might be saved as navigation.html or navigation.ssi.
    Use the following SSI tag to include that HTML in each page.

    <!--#include virtual="path to file/include-file.html" -->

    Use that same code on every page that you want to include the file.

    PHP

    PHP is another server level programming language that allows you to include HTML documents inside your pages, much the same as SSI. Like SSI, this is a server level technology.

    Save the HTML for the common elements of your site to separate files. For example, your navigation section might be saved as navigation.html or navigation.php.
    Use the following PHP code to include that HTML in each page.

    <?php
    require($DOCUMENT_ROOT . "path to file/include-file.html");
    ?>

    Use that same code on every page that you want to include the file.

    ASP

    Active Server Pages are another way to include HTML within your Web pages. Again, as long as your server supports ASP, you can include files using it.

    Save the HTML for the common elements of your site to separate files. For example, your navigation section might be saved as navigation.html or navigation.asp.
    Use the include directive to include that HTML in each page.

    <!--#include file="path to file/include-file.html"-->

    Use that same code on every page that you want to include the file.

    JavaScript

    JavaScript is another way to include HTML within the pages of your site. This has the advantage of not requiring server-level programming. But it's a little more complicated than the server-level include methods.

    Save the HTML for the common elements of your site to a JavaScript file. Any HTML written in this file, must be printed to the screen with the document.write function.
    Use a script tag to include the JavaScript file on your pages.

    <script type="text/javascript" src="path to file/include-file.js"> </script>

    Use that same code on every page that you want to include the file.

    Other Include Methods

    There are many other ways to include HTML on your pages. Some are more complicated than others.

    CGI
    You can use Perl or another CGI programming language to create your pages and then include whatever you want, either as "require" files or by reading them in manually.
    Flash
    If you want to build your site entirely in Flash, you can then use it to include elements of the site.
    Frames
    Instead of using the same elements over and over in multiple pages, you can create a framed site where the frames are the duplicated portions of the site.
    Content Management
    Templating is one of the major selling points of CMS. Only the managers have access to change the template portions of the site, while content developers change the dynamic sections.. It's useful and I think the article will help you.

    If you have any questions, please write.

    Regards,
    Jordan!
     
    jenev, Jul 4, 2012 IP
  3. Rankx

    Rankx Active Member

    Messages:
    119
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    50
    #3
    Or you can simply rename the HTML file as a php file and include it since it will be .php
     
    Rankx, Jul 4, 2012 IP
  4. rainat

    rainat Member

    Messages:
    66
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #4
    Javascript can do it like janev said..thanks for the explenation
     
    rainat, Jul 5, 2012 IP