TinTod
asked on
Include content from one HTML page in a div on another
Im looking for a relatively easy way to Include content from one HTML page into a div on another. Specifically, I'm hoping to designate a character count or line count to include on div.
I greatly appreciate any help.
Tin
I greatly appreciate any help.
Tin
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Are you hosted on a server that has PHP enabled?
ASKER
No.
Then you're stuck with javascript includes. There are several ways to do it, just google javascript includes.
Or create a file called includes.js
Inside add this at the top:
Replace head with whatever you want that section named.
Then for your "head" area insert this:
Increment the number in the square brackets for each line, here's an example:
Then add a var line and a chunk of text like the above to create your entire document. This way you only need one includes.js file and you can fill it with as much content as you want. For example:
Then at the very bottom of the includes.js add this:
Then in each file you'll use the text in the include.js file include the .js script:
Then use script to include the sections:
Does that make sense?
Or create a file called includes.js
Inside add this at the top:
var head = new Array();
Replace head with whatever you want that section named.
Then for your "head" area insert this:
head[0] = '[this is where you put your code or text including html]';
Increment the number in the square brackets for each line, here's an example:
head[0] = '<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />';
head[1] = '<link href="css/Demo.css" rel="stylesheet" type="text/css" />';
head[2] = '<link href="css/Dem_2Graphs.css" rel="alternate stylesheet" title="Graphs2Across" type="text/css" />';
head[3] = '<link href="css/Demo_3Graphs.css " rel="alternate stylesheet" title="Graphs3Across" type="text/css" />';
head[4] = '<link href="css/dropline_nav.css " rel="stylesheet" type="text/css" />';
head[5] = '<!--[if IE 6]> <link href="css/Demo_IE6.css" rel="stylesheet" type="text/css"> <![endif]-->';
head[6] = '<!--[if IE 7]> <link href="css/Demo_IE7.css" rel="stylesheet" type="text/css"> <![endif]-->';
head[7] = '<!--[if IE 8]> <link href="css/Demo_IE8.css" rel="stylesheet" type="text/css"> <![endif]-->';
head[8] = '<script type="text/javascript" src="Scripts/AC_RunActiveC ontent.js" ></script> ';
head[9] = '<script type="text/javascript" src="Scripts/script.js"></ script>';
head[10] = '<script type="text/javascript" src="Scripts/styleswitcher .js"></scr ipt>';
head[11] = '<script type="text/javascript" src="Scripts/browser_detec t.js"></sc ript>';
head[12] = '<script type="text/javascript" src="Scripts/popup.js"></s cript>';
head[13] = '<script type="text/javascript" src="Scripts/tabs_optimize d.js"></sc ript>';
head[14] = '</head>';
head[15] = '<body>';
head[16] = '<table align="center" cellpadding="0" cellspacing="0" border="0" width="974" style="margin: 0px auto;"><tr><td width="309"><!-- Required to center in all browsers. -->';
head[17] = '<div id="left_shadow"><div id="right_shadow">';
head[18] = '<div id="container">';
head[1] = '<link href="css/Demo.css" rel="stylesheet" type="text/css" />';
head[2] = '<link href="css/Dem_2Graphs.css"
head[3] = '<link href="css/Demo_3Graphs.css
head[4] = '<link href="css/dropline_nav.css
head[5] = '<!--[if IE 6]> <link href="css/Demo_IE6.css" rel="stylesheet" type="text/css"> <![endif]-->';
head[6] = '<!--[if IE 7]> <link href="css/Demo_IE7.css" rel="stylesheet" type="text/css"> <![endif]-->';
head[7] = '<!--[if IE 8]> <link href="css/Demo_IE8.css" rel="stylesheet" type="text/css"> <![endif]-->';
head[8] = '<script type="text/javascript" src="Scripts/AC_RunActiveC
head[9] = '<script type="text/javascript" src="Scripts/script.js"></
head[10] = '<script type="text/javascript" src="Scripts/styleswitcher
head[11] = '<script type="text/javascript" src="Scripts/browser_detec
head[12] = '<script type="text/javascript" src="Scripts/popup.js"></s
head[13] = '<script type="text/javascript" src="Scripts/tabs_optimize
head[14] = '</head>';
head[15] = '<body>';
head[16] = '<table align="center" cellpadding="0" cellspacing="0" border="0" width="974" style="margin: 0px auto;"><tr><td width="309"><!-- Required to center in all browsers. -->';
head[17] = '<div id="left_shadow"><div id="right_shadow">';
head[18] = '<div id="container">';
Then add a var line and a chunk of text like the above to create your entire document. This way you only need one includes.js file and you can fill it with as much content as you want. For example:
var head = new Array(); // This includes everything in the Head tags.
var header = new Array(); // This includes the header information.
var content_start = new Array(); // This is the start of the content area.
var navigation = new Array(); // This is for the navigation.
var header = new Array(); // This includes the header information.
var content_start = new Array(); // This is the start of the content area.
var navigation = new Array(); // This is for the navigation.
Then at the very bottom of the includes.js add this:
function show(i)
{
for (x in i)
{
document.write(i[x]+'\n')
}
}
{
for (x in i)
{
document.write(i[x]+'\n')
}
}
Then in each file you'll use the text in the include.js file include the .js script:
<script type="text/javascript" src="includes.js"></script >
Then use script to include the sections:
<script type="text/javascript">sho w(head);</ script>
Does that make sense?
ASKER
It does. Thanks so much. I really appreciate your time.
Take care.
-T
Take care.
-T
You're welcome.
ASKER