Connecting Tech Pros Worldwide Help | Site Map

Call external file with <script src="content.js"></script> insteadof SSI.

BlueŽ
Guest
 
Posts: n/a
#1: Jul 23 '05
I would like to call the content of content.htm (containing only HTML
codes) into index.htm.

This is usually done by renaming index.htm to index.shtml and use this tag:

<!--#include file="content.htm" -->

But I do not want to use SSI. Is it possible to call it using something
like:

<script src="content.js"></script>

If yes, how should content.js look like?
Martin Honnen
Guest
 
Posts: n/a
#2: Jul 23 '05

re: Call external file with <script src="content.js"></script> insteadof SSI.




BlueŽ wrote:
[color=blue]
> I would like to call the content of content.htm (containing only HTML
> codes) into index.htm.
>
> This is usually done by renaming index.htm to index.shtml and use this tag:
>
> <!--#include file="content.htm" -->
>
> But I do not want to use SSI. Is it possible to call it using something
> like:
>
> <script src="content.js"></script>
>
> If yes, how should content.js look like?[/color]

The HTML element to include another document on the client is
<iframe src="content.html"
width="putsomewidthere"
height="putsomeheighthere"></iframe>

--

Martin Honnen
http://JavaScript.FAQTs.com/
BlueŽ
Guest
 
Posts: n/a
#3: Jul 23 '05

re: Call external file with <script src="content.js"></script> insteadof SSI.


Martin Honnen wrote:[color=blue]
>
>
> BlueŽ wrote:
>[color=green]
>> I would like to call the content of content.htm (containing only HTML
>> codes) into index.htm.
>>
>> This is usually done by renaming index.htm to index.shtml and use this
>> tag:
>>
>> <!--#include file="content.htm" -->
>>
>> But I do not want to use SSI. Is it possible to call it using
>> something like:
>>
>> <script src="content.js"></script>
>>
>> If yes, how should content.js look like?[/color]
>
>
> The HTML element to include another document on the client is
> <iframe src="content.html"
> width="putsomewidthere"
> height="putsomeheighthere"></iframe>
>[/color]

Negative. Using iframe will cause a box with a fixed width to be
created. I need the width of the cell adjusted automatically/accordingly
to the content of content.htm.
Hywel Jenkins
Guest
 
Posts: n/a
#4: Jul 23 '05

re: Call external file with <script src="content.js"></script> insteadof SSI.


In article <d6q4il$2a2g$1@news10.jaring.my>, superbaby@myjaring.net
says...[color=blue]
> I would like to call the content of content.htm (containing only HTML
> codes) into index.htm.
>
> This is usually done by renaming index.htm to index.shtml and use this tag:
>
> <!--#include file="content.htm" -->
>
> But I do not want to use SSI. Is it possible to call it using something
> like:
>
> <script src="content.js"></script>
>
> If yes, how should content.js look like?[/color]

Full of document.write() function calls I would guess.

--
Hywel

Kill the Crazy Frog
http://www.petitiononline.com/crzyfrg/
McKirahan
Guest
 
Posts: n/a
#5: Jul 23 '05

re: Call external file with <script src="content.js"></script> insteadof SSI.


"Hywel Jenkins" <hywel.jenkins@gmail.com> wrote in message
news:MPG.1cfacc83b3880049896dc@news.eclipse.net.uk ...[color=blue]
> In article <d6q4il$2a2g$1@news10.jaring.my>, superbaby@myjaring.net
> says...[color=green]
> > I would like to call the content of content.htm (containing only HTML
> > codes) into index.htm.
> >
> > This is usually done by renaming index.htm to index.shtml and use this[/color][/color]
tag:[color=blue][color=green]
> >
> > <!--#include file="content.htm" -->
> >
> > But I do not want to use SSI. Is it possible to call it using something
> > like:
> >
> > <script src="content.js"></script>
> >
> > If yes, how should content.js look like?[/color]
>
> Full of document.write() function calls I would guess.
>
> --
> Hywel
>
> Kill the Crazy Frog
> http://www.petitiononline.com/crzyfrg/[/color]

Or build an array and "document.write" the join; as in:

var i = 0;
var a = new Array();
a(i++) = "<table border='1'>";
a(i++) = "<tr>";
a(i++) = " <td>Hello World!</td>";
a(i++) = "</tr>";
a(i++) = "</table>";
document.write a.join("\n");


Martin Honnen
Guest
 
Posts: n/a
#6: Jul 23 '05

re: Call external file with <script src="content.js"></script> insteadof SSI.




BlueŽ wrote:
[color=blue]
> Negative. Using iframe will cause a box with a fixed width to be
> created. I need the width of the cell adjusted automatically/accordingly
> to the content of content.htm.[/color]

Script can try to adjust the iframe:
<http://www.faqts.com/knowledge_base/view.phtml/aid/1076/fid/127>

If you really need to load some resource from your server then there are
also some browser dependent ways, IE/Win has the download behaviour
<http://www.faqts.com/knowledge_base/view.phtml/aid/1268/fid/126>
with Mozilla, newest Opera and Safari you could try to use
XMLHttpRequest and read responseText (as long as you do not run into
encoding/decoding problems), then you could try to set innerHTML of an
existing element in the document.

--

Martin Honnen
http://JavaScript.FAQTs.com/
McKirahan
Guest
 
Posts: n/a
#7: Jul 23 '05

re: Call external file with <script src="content.js"></script> insteadof SSI.


"McKirahan" <News@McKirahan.com> wrote in message
news:xaWdnb4YwsogIg3fRVn-sw@comcast.com...[color=blue]
> "Hywel Jenkins" <hywel.jenkins@gmail.com> wrote in message
> news:MPG.1cfacc83b3880049896dc@news.eclipse.net.uk ...[color=green]
> > In article <d6q4il$2a2g$1@news10.jaring.my>, superbaby@myjaring.net
> > says...[color=darkred]
> > > I would like to call the content of content.htm (containing only HTML
> > > codes) into index.htm.
> > >
> > > This is usually done by renaming index.htm to index.shtml and use this[/color][/color]
> tag:[color=green][color=darkred]
> > >
> > > <!--#include file="content.htm" -->
> > >
> > > But I do not want to use SSI. Is it possible to call it using[/color][/color][/color]
something[color=blue][color=green][color=darkred]
> > > like:
> > >
> > > <script src="content.js"></script>
> > >
> > > If yes, how should content.js look like?[/color]
> >
> > Full of document.write() function calls I would guess.
> >
> > --
> > Hywel
> >
> > Kill the Crazy Frog
> > http://www.petitiononline.com/crzyfrg/[/color]
>
> Or build an array and "document.write" the join; as in:
>
> var i = 0;
> var a = new Array();
> a(i++) = "<table border='1'>";
> a(i++) = "<tr>";
> a(i++) = " <td>Hello World!</td>";
> a(i++) = "</tr>";
> a(i++) = "</table>";
> document.write a.join("\n");
>
>[/color]

Try this instead:

var html = [
"<table border='1'>",
"<tr>",
" <td>Hello World!</td>",
"</tr>",
"</table>",
""];
document.write(html.join(""));


Lasse Reichstein Nielsen
Guest
 
Posts: n/a
#8: Jul 23 '05

re: Call external file with <script src="content.js"></script> insteadof SSI.


"McKirahan" <News@McKirahan.com> writes:
[color=blue]
> Try this instead:[/color]

... or while we are at it:

document.write("<table>",
"<tr>",
"<td>Hello World!<\/td>",
"</tr>",
"</table>");

/L
--
Lasse Reichstein Nielsen - lrn@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Random
Guest
 
Posts: n/a
#9: Jul 23 '05

re: Call external file with <script src="content.js"></script> insteadof SSI.


Don't know how relevant it is to your specific needs, but I figured I'd
add a few alternatives in case you find them a little more palatable:


.... why not just use an iframe?
.... PHP include() can do this, too.
.... you might load it as content.htm in an invisible iframe, with an
onLoad that dumps document.body.innerHTML into the element where you're
wanting to drop this content. But IE sometimes dislikes this method.


The bad part of using JavaScript for this is that search engines WILL
NOT INDEX this content. Better to use an iframe or an include.

VK
Guest
 
Posts: n/a
#10: Jul 23 '05

re: Call external file with <script src="content.js"></script> insteadof SSI.


You may use XMLHTTPRequest (google for it) in your script. This way you
can load internally your content file, pull out its body (or whatever
part you need) using DOM methods and insert it in any part of your
index page. It works in IE and FF, presumably in latest NN. In Safary
and Opera whis object is broken. Also be aware of security restrictions.

Thomas 'PointedEars' Lahn
Guest
 
Posts: n/a
#11: Jul 23 '05

re: Call external file with <script src="content.js"></script> insteadof SSI.


Lasse Reichstein Nielsen wrote:
[color=blue]
> "McKirahan" <News@McKirahan.com> writes:[color=green]
>> Try this instead:[/color]
>
> .. or while we are at it:
>
> document.write("<table>",
> "<tr>",
> "<td>Hello World!<\/td>",
> "</tr>",
> "</table>");[/color]

But this, originating from client-side JavaScript v1.0 up to v1.3[1], is
less likely to be supported than the former is, it is proprietary, and
so should be deprecated. Both the MSDN Library[2] and W3C DOM Level 1+
HTML[3] define a different syntax, using only one argument for that method.
(I currently cannot test with IE, though.)


PointedEars
___________
[1]
<http://devedge-temp.mozilla.org/library/manuals/2000/javascript/1.3/reference/document.html#1221642>
[2]
<http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/write.asp>
[3] <http://www.w3.org/TR/DOM-Level-1/level-one-html.html#method-write>
<http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-75233634>
Closed Thread