By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,825 Members | 1,184 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,825 IT Pros & Developers. It's quick & easy.

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

P: n/a
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?
Jul 23 '05 #1
Share this Question
Share on Google+
10 Replies


P: n/a


Blue® wrote:
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?


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/
Jul 23 '05 #2

P: n/a
Martin Honnen wrote:


Blue® wrote:
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?

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


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.
Jul 23 '05 #3

P: n/a
In article <d6***********@news10.jaring.my>, su*******@myjaring.net
says...
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?


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

--
Hywel

Kill the Crazy Frog
http://www.petitiononline.com/crzyfrg/
Jul 23 '05 #4

P: n/a
"Hywel Jenkins" <hy***********@gmail.com> wrote in message
news:MP***********************@news.eclipse.net.uk ...
In article <d6***********@news10.jaring.my>, su*******@myjaring.net
says...
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?


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

--
Hywel

Kill the Crazy Frog
http://www.petitiononline.com/crzyfrg/


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");
Jul 23 '05 #5

P: n/a


Blue® wrote:
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.


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/
Jul 23 '05 #6

P: n/a
"McKirahan" <Ne**@McKirahan.com> wrote in message
news:xa********************@comcast.com...
"Hywel Jenkins" <hy***********@gmail.com> wrote in message
news:MP***********************@news.eclipse.net.uk ...
In article <d6***********@news10.jaring.my>, su*******@myjaring.net
says...
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?


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

--
Hywel

Kill the Crazy Frog
http://www.petitiononline.com/crzyfrg/


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");


Try this instead:

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

P: n/a
"McKirahan" <Ne**@McKirahan.com> writes:
Try this instead:


... or while we are at it:

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

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #8

P: n/a
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.

Jul 23 '05 #9

P: n/a
VK
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.

Jul 23 '05 #10

P: n/a
Lasse Reichstein Nielsen wrote:
"McKirahan" <Ne**@McKirahan.com> writes:
Try this instead:


.. or while we are at it:

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


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>
Jul 23 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.