O'Reilly Forums: Insert Html Into Html - O'Reilly Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Insert Html Into Html How do I insert text for a changing document into multiple firm docs?

#1 User is offline   BungeeKY 

  • New Member
  • Pip
  • Group: Members
  • Posts: 1
  • Joined: 15-June 10

Posted 15 June 2010 - 07:19 AM

I am developing a great website I am coding completely from my work with the Head First Labs HTML (with CSS & XHTML) books. I have done good work this book but think I'm suddenly out of my depth. There's an index page and 8 subpages on the site and I'm using two CSS stylesheets.

In one section of each of these pages, there is text I want to regularly update WITHOUT having to cut and paste it into each of the 9 pages. Basically, I have some text that's going to change regularly and I want the changes to show up in 9 pages.

I've not found an html tag way to do this and want to make it work so changing that one bit of updated text does not require updating (and pasting code into) 9 pages.

Depending on how I pasted it, I would style it so it keeps the CSS styling so it shows up the same on each page. Is this possible with HTML? Someone please advise...

Any help would be greatly appreciated!

Thank you,
Benjamin
0

#2 User is offline   ajspeller 

  • Active Member
  • PipPip
  • Group: Members
  • Posts: 31
  • Joined: 23-April 08
  • Location:Virginia Beach, Virginia
  • Interests:Movies, Computers, Music

Posted 24 July 2010 - 12:34 PM

Hi,

I used to maintain a website for a church and here is a solution that I used. I created an external file named, mybanner_small.js, in javascript that outputs HTML as follows ...

CODE
// JavaScript Document

var cText = '';

cText += ' <p id=\"heading\">';
cText += ' <img alt=\"Kingdom First Ministries International Image\" src=\"images/banner_small.png\" />';
cText += ' </p>';


document.write(cText);


I then reference that external javascript file in each of my HTML pages as follows ...

CODE
<script type="text/javascript" src="scripts/mybanner_small.js"></script>



In this case if the banner filename changes I just had to update the .js file with the new name and the rest of pages would display the change accordingly.

Be sure to ...
1) escape characters as needed in the .js file so the html is composed properly
2) place the script tags in the html file in the location where you want to see text unless of course if your using css for page layout.



This post has been edited by ajspeller: 24 July 2010 - 12:55 PM

0

#3 User is offline   vhss 

  • New Member
  • Pip
  • Group: Members
  • Posts: 3
  • Joined: 24-August 10
  • Interests:Books and movies.

  Posted 24 August 2010 - 02:30 PM

Hi BungeeKY! There is another option

<object classid="clsid:123" data="insertion.html">

<p>content</p>

</object>

Actually, by using JS or php you'll get even more options. Good luck!

huh.gif

When you can't find an answer... http://dld.bz/tdrW
Why the free is an opportunity?.. http://bit.ly/aHpeat
0

#4 User is offline   MadTony 

  • New Member
  • Pip
  • Group: Members
  • Posts: 1
  • Joined: 17-August 11

Posted 17 August 2011 - 05:38 PM

View Postvhss, on 24 August 2010 - 02:30 PM, said:

Hi <b>BungeeKY</b>! There is another option

<object classid="clsid:123" data="insertion.html">

<p>content</p>

</object>

Actually, by using JS or php you'll get even more options. Good luck!

<img src="http://forums.oreilly.com/public/style_emoticons/<#EMO_DIR#>/huh.gif" style="vertical-align:middle" emoid=":huh:" border="0" alt="huh.gif" />



This worked for me. I tried it while working on the new members area at LA Fitness. Didn't think it would, but it did.
0

#5 User is offline   Chicago Photography Academy 

  • New Member
  • Pip
  • Group: Members
  • Posts: 1
  • Joined: 20-September 11
  • Gender:Male
  • Location:Chicago
  • Interests:Photography Classes Chicago

Posted 20 September 2011 - 02:28 AM

View PostBungeeKY, on 15 June 2010 - 07:19 AM, said:

I am developing a great website I am coding completely from my work with the Head First Labs HTML (with CSS & XHTML) books. I have done good work this book but think I'm suddenly out of my depth. There's an index page and 8 subpages on the site and I'm using two CSS stylesheets.

In one section of each of these pages, there is text I want to regularly update WITHOUT having to cut and paste it into each of the 9 pages. Basically, I have some text that's going to change regularly and I want the changes to show up in 9 pages.

I've not found an html tag way to do this and want to make it work so changing that one bit of updated text does not require updating (and pasting code into) 9 pages.

Depending on how I pasted it, I would style it so it keeps the CSS styling so it shows up the same on each page. Is this possible with HTML? Someone please advise...

Any help would be greatly appreciated!

Thank you,
Benjamin

If your server has PHP you can simply rename your pages with a .php extension replacing the .html and put this line of code wherever you wish to include the one piece of data that you want to keep separate:
<?php include_once 'your filename here'; ?>

Teaching Photography in Chicago ipaschools.com
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users