PDA

Click to See Complete Forum and Search --> : Javascipt (include another page)


Jeremy Martin
Feb 6th, 2001, 11:23 PM
Ok I have these two different webpages. One has about two lines of text (page y) on and the other is a full page with content (page x).

What I would like to do is be able to include page y on page x or for that matter include page y on any page in my website. I know you can do this in frontpage but its method is clummsy and doesn't work well. I am basically looking for a Javascipt that would let me include one page on another, anyone know how to write such a script?

Jeremy

Mark Sreeves
Feb 7th, 2001, 06:41 AM
Here's one way...

pageX.html

<HTML>

<body>

page X page x page X <BR>
page X page x page X <BR>
page X page x page X <BR>
page X page x page X <BR>


<SCRIPT SRC="pageY.js"><!--
//--></SCRIPT>
page X page x page X <BR>
page X page x page X <BR>
page X page x page X <BR>
page X page x page X <BR>

</body>
</HTML>


pageY.js


document.write('Hello. This is a line from pageY<BR>');
document.write('Second line from pageY<BR>');

Feb 7th, 2001, 01:50 PM
As I have posted in the other thread - this web site may help for this problem and other java scripts you might want to use. The web site is : -

http://www.javascriptsource.com

Have fun!!!!!

sail3005
Feb 7th, 2001, 08:20 PM
does it have to use javascript? You could do it very easy by using a server side include. But if it must be javascript, mark's way is the best.

Mark Sreeves
Feb 8th, 2001, 02:34 AM
zippa Try it and see! :)

rculver One thing that really annoys me is "have a look at this site there might be somthing there" sort of replies. EXACT links please!

I had a quick look at javascriptsource and I wasn't impressed. I got javascript errors and that was using IE5!!!!!!!

I use www.irt.org as a main source of reference.

Jeremy Martin as, sail3005 says, reading the page on the server side is the best (only) way to do it because you would then be able to replace line feeds with <BR>s and the like.

Is server-side scripting an option for you?

Jeremy Martin
Feb 8th, 2001, 12:48 PM
Yes server side scripting is certinaly an option but I not really done this so if someone could point me in the right direction that would be verry appreciated.

Jeremy

sail3005
Feb 8th, 2001, 06:58 PM
Here is an example:

some common include types are .inc, .asp, .shtml.

included.inc:


put your page contents here



then put this in the page that you want the add the above page to:

<!--#include file="included.inc"-->

-or-

<!--#include virtual="included.inc"-->


file will look for the file in the directory that you have it in, or a directory below it.

virtual will start in the root directory.

hope this helps. If you need any more help let me know, because this is one are that i am actually good in!

zippa
Feb 8th, 2001, 07:55 PM
Mark: Javascript has a 40 word limit or something of that sort inside "document.write" doesn't it?

Mark Sreeves
Feb 9th, 2001, 02:35 AM
zippa: I wasn't aware of a limit but you could use multiple document.write()s