Results 1 to 2 of 2

Thread: .html dan .inc

  1. #1
    Join Date
    May 2007
    Location
    Senawang
    Posts
    1
    Rep Power
    0

    .html dan .inc

    tompang tanya, boleh ke kalau kita gunakan fungsi .inc kat dalam html? biasanya .inc ni digunakan dlm php untuk panggil file .inc tu kan? masa saya belajar dulu lecturer saya kata .inc ni kita guna kalau nak letak header ngan footer so bila nk coding php tak payah nak ulang kali taip code utk header ngan footer tu. just letak je function include.

    tapi mcm mana pulak kalau html? boleh ke? yang saya tau, kalau html boleh la guna frameset. tapi rasanya guna frame @ frameset utk website tak berapa bagus dari segi SEO dia. Google tak suka kan?

    jadi, mcm mana? takkan solution dia hanya dgn guna php sahaja? tak best la bila nk buat website yg ada format .htm ngan .php dlm web tu nanti. kalau boleh biar .htm je semua pastu ada la include .css sikit.

  2. #2
    Join Date
    Aug 2006
    Location
    Malaysia
    Posts
    1,576
    Rep Power
    196
    For client-side, generally, there is "no official way" to include the pure HTML content except the frameset, although CSS and Javascript files can be included at the client side. Typically, it has to use the web server to process file inclusion for the contents in the HTML.

    But there is a workaround to leverage Javascript to mimic it. Refer to http://ask-leo.com/how_do_i_include_...e_another.html

    http://htmlhelp.com/faq/html/design.html#include-file

    5.1. How do I include one file in another?

    HTML itself offers no way to seamlessly incorporate the content of one file into another.

    True dynamic inclusion of one HTML document (even in a different "charset") into another is offered by the OBJECT element, but due to shortcomings of browser versions in current use, it seems unwise to rely on this yet for essential content. The same can be said for IFRAME.

    Two popular ways of including the contents of one file seamlessly into another for the WWW are preprocessing and server-side inclusion. A preprocessor converts its source into a plain HTML document that you publish on your server. In contrast, documents that use server-side inclusion are processed every time the document is retrieved from the server.

    Preprocessing techniques include the C preprocessor and other generic text manipulation methods, and several HTML-specific processors.

    Beware of making your "source code" non-portable. Also, the HTML can only be validated after preprocessing, so the typical cycle "Edit, Check, Upload" becomes "Edit, Preprocess, Check, Upload" (here, "Check" includes whatever steps you use to preview your pages: validation, linting, management walk-through etc.; and "upload" means whatever you do to finally publish your new pages to the web server).

    A much more powerful and versatile preprocessing technique is to use an SGML processor (such as the SP package) to generate your HTML; this can be self-validating.

    Examples of server-side inclusion are Server Side Includes (SSI, supported by Apache, NCSA, and other web servers), and Microsoft's Active Server Pages (ASP, supported by MS IIS). Processing occurs at the time the documents are actually retrieved. A typical inclusion looks like

    <!--#include virtual="/urlpath/to/myfile.htm" -->

    However, be sure to consult your own server's documentation, as the details vary somewhat between implementations. The whole directive gets replaced by the contents of the specified file.

    Using server-side inclusion (a potentially powerful tool) merely as a way to insert static files such as standard header/footers has implications for perceived access speed and for server load, and is better avoided on heavily loaded servers. If you use it in this way, consider making the result cacheable (e.g., via "XBitHack full" on Apache; setting properties of the "Response" object in ASP).

    Proper HTML validation of server-side inclusion is only possible after server-side processing is done (e.g. by using an on-line validator that retrieves the document from the server).

    Another approach is to create a database-backed site, as described in Philip and Alex's Guide to Web Publishing. A simple change to the database template instantly changes the whole site.

    Finally, note that if the included file contains arbitrary plain text, then some provision must be made to convert the characters "&" and "<" (in the plain text file) to the entities "&amp;" and "&lt;" (in the HTML document).
    The workaround:
    http://ask-leo.com/how_do_i_include_...e_another.html
    Client Side Includes

    As I mentioned above, there is no actual syntax for a client-side include but we can mimic one using Javascript. For example:

    <script src="b.js" type="text/javascript"> </script>

    When encountered the browser downloads the script "b.js", executes it, and prints any output that the script might generate as if it were inline HTML.
    Technically that's not an include but the script "b.js" could be nothing more than a series of javascript "print" statements such as these:

    document.write("<table>")
    document.write("<tr>")
    ... and so on


    You can see it's "printing" the HTML you want included. In other words, if you can format your include file as a series of javascript prints, you can use client-side include to insert it.

    Now things can get very interesting, because we'll introduce two things: remote includes, and CGI programs, into the mix.
    ...
    ...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. PSD to HTML/CSS
    By therion in forum Advertise Your Services
    Replies: 0
    Last Post: 24-12-2008, 03:06 AM
  2. html
    By hafiza in forum Website Design
    Replies: 9
    Last Post: 23-04-2008, 11:17 AM
  3. rel in html
    By yipguseng in forum Website Programming
    Replies: 3
    Last Post: 06-05-2007, 04:26 AM
  4. PHP into HTML
    By arthermax in forum Website Programming
    Replies: 4
    Last Post: 18-04-2007, 07:03 PM
  5. html builder?
    By fadlee in forum Website Design
    Replies: 7
    Last Post: 06-10-2004, 06:10 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Search Engine Optimization by vBSEO 3.5.0 RC1 PL1

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37