trying to document.write() a SSI

G

Greg Brant

my script is

document.write("<!-- #include
virtual\"http://www.where-ever.com/whatevere.html\" -->")

but in the html (view source) i get

---------------------------------------------------
<script language="Javascript" type="text/Javascript">
document.write("\
-----------------------------------------------------
and thats the end of the document..

i also have some more document.write()'s above this in the same script
tag and these are not executed.. im guessing because it doesent get to
the </script> tag??

also im guessing that the reason its stopping is because its
encountering the html comment sequence "<!--".

so how do i write this safley?

cheers

Greg
 
R

Richard Formby

Greg Brant said:
my script is

document.write("<!-- #include
virtual\"http://www.where-ever.com/whatevere.html\" -->")

but in the html (view source) i get

---------------------------------------------------
<script language="Javascript" type="text/Javascript">
document.write("\
-----------------------------------------------------
and thats the end of the document..

i also have some more document.write()'s above this in the same script
tag and these are not executed.. im guessing because it doesent get to
the </script> tag??

also im guessing that the reason its stopping is because its
encountering the html comment sequence "<!--".

It doesn't matter. Even if you got the script to work it wouldn't work. SSI
is done server side. That is why it is called Server Side include.

By the time your script gets to execute you are client side, no further
access to the server.
 
K

kaeli

any suggestions how can i do what im trying to achieve?

Assuming you're trying to include the content of one page within
another...
Use an IFRAME if you have no server-side language available (aside from
SSI).
If you have ASP or JSP, they can include pages in the output. I'm pretty
sure Perl can, too.

If you're trying to include pages only if some condition is true, and
that condition is determined on the client, you'll need javascript and
an IFRAME, as far as I know.

I'm out of ideas after that. :)

--
 
R

Richard Cornford

Assuming you're trying to include the content of one page
within another...
Use an IFRAME if you have no server-side language available
(aside from SSI).
If you have ASP or JSP, they can include pages in the output.
I'm pretty sure Perl can, too.

If you're trying to include pages only if some condition is
true, and that condition is determined on the client, you'll
need javascript and an IFRAME, as far as I know.

The greater flexibility of server-side scripting aside, I can't see a
difference between:-

< some HTML >
<script type="text/javascript">
document.write("<!-- [SSI inserted HTML] -->");
document.write("something else");
</script>
< some more HTML>

- and:-

< some HTML >
<!-- [SSI inserted HTML] -->
<script type="text/javascript">
document.write("something else");
</script>
< some more HTML>

- Except that the latter is not JavaScript dependent and avoids having
to worry about the appropriateness of the characters within the include
in the context of a JavaScript string.

That is, if the point is to get the included HTML onto the page why not
include it in the HTML?

Richard.
 
K

kaeli

The greater flexibility of server-side scripting aside, I can't see a
difference between:-
<snip>

Me neither actually.
It's early. :)
That is, if the point is to get the included HTML onto the page why not
include it in the HTML?

I think the OP wanted the html included only if some condition were
satisfied. It was unclear if the condition was decided on the client or
on the server. Actually, the whole question was unclear. *heh*

--
 
G

Greg Brant

sorry fo being unclear.

The idea is that if a user has filled in a for then a page is included,
that page will take a variable posted from the form as an argument..

so.

the page to be included needs to process the variables and then be
included..

but i see that (obviously) SSI is server side..

I do have access to PHP so i am going to do it this way.. i was trying
to do it without php as a collegue is not proficient with the language

thanks for your response, somtimes the obvious is too obvious


cheers

Greg
 
@

@SM

Greg Brant a ecrit :
sorry fo being unclear.

The idea is that if a user has filled in a for then a page is included,
that page will take a variable posted from the form as an argument..

you certainly can do that with JavaScript.

The form
<html>
<form action="js_read.html">
Give your Name :
<input type=text name="MyArgument">
<input type=submit value="GO">
</fomr></html>

to reach a specific page

js_read.html
<html>
<script type="text/javascript">
this.location.escape();
if(MyArgument!='') self.location='trucmuche/'+MyArgument+'.htm';
</script>
Sorry JavaScript error
</html>

to write in a page

js_read.html
<html>
<script type="text/javascript">
this.location.escape();
function dc(txt) { document.write(txt);}
if(MyArgument!='') trucmuche ='<h2>Hello '+MyArgument+'</h2>';
else trucmuche ='';
</script>
<body>
blabla
<script type="text/javascript">
dc(trucmuche);
</script>
re blah blah
</body>
</html>

and/or use ssi same way


--
******** (enlever/remove [OTER_MOI] du/from reply url) *******
Stéphane MORIAUX : mailto:[email protected]
Aide aux Pages Perso (images & couleurs, formulaire, CHP, JS)
http://perso.wanadoo.fr/stephane.moriaux/internet/
**************************************************************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top