/    Sign up×
Community /Pin to ProfileBookmark

Including content from another file

I’m sure it’s possible to update content in a separate file and have it displayed in your HTML page ‘dynamically’ by linking to the content file…if that makes sense.

Problem is, I have no idea what this technique would be called so I haven’t had much luck searching for how to do it.

Can anyone tell me how to do this? What I want is to create my page header once only, and then call it into each page without needing to cut and paste it into every document. Is it possible to do this WITHOUT using frames? Cos if possible I want to avoid that.

Thanks for any advice.

Toby

to post a comment
HTML

3 Comments(s)

Copy linkTweet thisAlerts:
@AdamGundryDec 29.2003 — Assuming you have a server-side language available, it is fairly easy. If not, it is near impossible. Here's how to do it for PHP and SSI:

http://webdevfaqs.com/php.php#include

Adam
Copy linkTweet thisAlerts:
@eviljoker7075Dec 29.2003 — can't you either:

a) link into it like you would with a css or javascript document

or

b)use an iframe?
Copy linkTweet thisAlerts:
@TheBearMayDec 29.2003 — May want to look at the <object> tag to see if it will do what you want.

From http://www.w3.org/TR/1999/REC-html401-19991224/struct/objects.html#h-13.3

[b]13.5 Notes on embedded documents[/b]

Sometimes, rather than linking to a document, an author may want to embed it directly into a primary HTML document. Authors may use either the IFRAME element or the OBJECT element for this purpose, but the elements differ in some ways. Not only do the two elements have different content models, the IFRAME element may be a target frame (see the section on specifying target frame information for details) and may be "selected" by a user agent as the focus for printing, viewing HTML source, etc. User agents may render selected frames elements in ways that distinguish them from unselected frames (e.g., by drawing a border around the selected frame).

An embedded document is entirely independent of the document in which it is embedded. For instance, relative URIs within the embedded document resolve according to the base URI of the embedded document, not that of the main document. An embedded document is only rendered within another document (e.g., in a subwindow); it remains otherwise independent.

For instance, the following line embeds the contents of embed_me.html at the location where the OBJECT definition occurs.

...text before...

<OBJECT data="embed_me.html">

Warning: embed_me.html could not be embedded.

</OBJECT>

...text after...

Recall that the contents of OBJECT must only be rendered if the file specified by the data attribute cannot be loaded.
[/quote]
×

Success!

Help @tobyw_1969 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...